Permalink
Browse files

fix(rest): fix axios include handling

  • Loading branch information...
RangerRick committed Jul 20, 2017
1 parent 8e4f42d commit e4618316dac0ec7c3293928919c5203d645441ee
Showing with 11 additions and 12 deletions.
  1. +11 −12 src/rest/AxiosHTTP.ts
View
@@ -2,9 +2,6 @@ import axios from 'axios';
import {AxiosStatic, AxiosInstance, AxiosRequestConfig} from 'axios';
import * as qs from 'qs';
/** @hidden */
declare const IS_WEB;
/** @hidden */
// tslint:disable-next-line
const URI = require('urijs');
@@ -147,22 +144,24 @@ export class AxiosHTTP extends AbstractHTTP {
throw new OnmsError('You must set a server before attempting to make queries using Axios!');
}
const allOptions = this.getOptions(options);
this.axiosObj = this.axiosImpl.create({
adapter: () => {
if (IS_WEB) {
return require('axios/lib/adapters/xhr');
} else {
return require('axios/lib/adapters/http');
}
},
const axiosOpts = {
auth: {
password: allOptions.auth.password,
username: allOptions.auth.username,
},
baseURL: server.url,
timeout: allOptions.timeout,
withCredentials: true,
});
} as AxiosRequestConfig;
if (typeof XMLHttpRequest !== 'undefined') {
axiosOpts.adapter = require('axios/lib/adapters/xhr.js');
} else if (typeof process !== 'undefined') {
axiosOpts.adapter = require('axios/lib/adapters/http.js');
}
this.axiosObj = this.axiosImpl.create(axiosOpts);
}
return this.axiosObj;
}

0 comments on commit e461831

Please sign in to comment.