2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-15 11:59:42 +03:00
Files
axios/lib/core/dispatchRequest.js
T
2015-03-18 17:21:15 -06:00

29 lines
736 B
JavaScript

'use strict';
/**
* Dispatch a request to the server using whichever adapter
* is supported by the current environment.
*
* @param {object} config The config that is to be used for the request
* @returns {Promise} The Promise to be fulfilled
*/
module.exports = function dispatchRequest(config) {
'use strict';
return new Promise(function (resolve, reject) {
try {
// For browsers use XHR adapter
if (typeof window !== 'undefined') {
require('../adapters/xhr')(resolve, reject, config);
}
// For node use HTTP adapter
else if (typeof process !== 'undefined') {
require('../adapters/http')(resolve, reject, config);
}
} catch (e) {
reject(e);
}
});
};