import request from 'superagent';
import superagentJsonapify from 'superagent-jsonapify';
import Settings from '../config/Settings'
import Timer from 'react-timer-mixin';



class Server {
  constructor(baseUrl) {
    this.baseUrl = baseUrl || Settings.getBaseUrlFor('test');
  }

  post(endPoint, data) {
    let promise = new Promise.race((resolve, reject) => {
      request
        .post(this.baseUrl + endPoint)
        .send(data)
        .set('Accept', 'application/json')
        .end((err, res) => {
          if(res) {
            resolve(res);
          } else if(err) {
            reject(err);
          }
        });
      });
    this.delay(7000).then(() => promise.reject)
    return promise;
  }

  get(endPoint, query) {

    let url = this.baseUrl + endPoint;
    let promise = new Promise((resolve, reject) => {
      Timer.setTimeout(() => { reject("Timed out") }, 5000);
      request
      .get(url)
      .query(query)
      .end((err, res) => {
        if(res) {
          resolve(res);
        } else if(err) {
          reject(err);
        }
      });
    });
    return promise;
  }
}

export default Server;

@@ -332,13 +332,8 @@
 mise
-.race
 ((re
@@ -348,24 +348,85 @@
 eject) =%3E %7B%0A
+      Timer.setTimeout(() =%3E %7B reject(%22Timed out%22) %7D, 5000);%0A
       reques
@@ -694,56 +694,8 @@
 %7D);%0A
-    this.delay(7000).then(() =%3E promise.reject)%0A
     

Fix Server post timeout