Replaces JQuery ajax requests with Axios requests
This commit is contained in:
parent
c295371f4d
commit
4fe9676318
|
@ -55,6 +55,7 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"app-module-path": "^1.0.3",
|
||||
"axios": "^0.18.0",
|
||||
"chart.js": "^2.4.0",
|
||||
"classnames": "^2.2.5",
|
||||
"draft-js": "^0.10.0",
|
||||
|
@ -65,6 +66,7 @@
|
|||
"localStorage": "^1.0.3",
|
||||
"lodash": "^3.10.0",
|
||||
"messageformat": "^0.2.2",
|
||||
"qs": "^6.5.2",
|
||||
"react": "^15.4.2",
|
||||
"react-chartjs-2": "^2.0.0",
|
||||
"react-document-title": "^1.0.2",
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
const _ = require('lodash');
|
||||
const $ = require('jquery');
|
||||
const axios = require('axios');
|
||||
const qs = require('qs');
|
||||
|
||||
const APIUtils = {
|
||||
|
||||
|
@ -11,21 +12,14 @@ const APIUtils = {
|
|||
data: data
|
||||
};
|
||||
|
||||
if(dataAsForm) {
|
||||
options = {
|
||||
url: path,
|
||||
type: method,
|
||||
data: data,
|
||||
processData: false,
|
||||
contentType: false
|
||||
};
|
||||
if(!dataAsForm){
|
||||
options.headers = {'content-type': 'application/x-www-form-urlencoded'},
|
||||
options.data = qs.stringify(options.data);
|
||||
}
|
||||
|
||||
$.ajax(options)
|
||||
.done(resolve)
|
||||
.fail((jqXHR, textStatus) => {
|
||||
reject(textStatus);
|
||||
});
|
||||
axios(options)
|
||||
.then((result) => resolve(result.data))
|
||||
.catch(() => reject());
|
||||
};
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue