Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/*
* Polyfills
*/
// require('babel/runtime');
import 'babel/polyfill';
/*
* Superagent promisification
*/
import { Request } from 'superagent';
Request.prototype.exec = function() {
let req = this;
return new Promise ((resolve, reject) => {
req.end((error, res) => {
if (error) return reject(error);
resolve(res);
});
});
};
import * as Promise from 'bluebird';
import { Request, Response } from 'superagent';
import { ApiStreamResponse } from '../constants/interfaces';
const R = require('superagent').Request
const _end = Promise.promisify(R.prototype.end);
export const apiBaseUrl = '/api';
export interface Options {
[name: string]: string;
}
export function end(request: Request): Promise {
return _end.apply(request);
}
export function stream(request: Request): ApiStreamResponse {
let response: ApiStreamResponse;
request.on('progress', e => {
if (response.onprogress) {
const xhr = e.target;
import request, {Request} from 'superagent';
Request.prototype.exec = function () {
return new Promise((resolve, reject) => {
this.end((error, res) => {
if (error) {
return reject(error);
}
resolve(res);
});
});
};
export default request;
import { Request } from 'superagent';
import request from 'superagent';
Request.prototype.exec = function() {
let req = this;
return new Promise ((resolve, reject) => {
req.end((error, res) => {
if (error) return reject(error);
resolve(res);
});
});
};
export default request;