2
0
mirror of https://github.com/tenrok/axios.git synced 2026-05-15 11:59:42 +03:00

Fixing axios to treat single string argument as URL

closes #116
This commit is contained in:
mzabriskie
2015-09-28 18:40:20 -06:00
parent eca2ac88eb
commit 95f0f00c77
2 changed files with 20 additions and 0 deletions
+7
View File
@@ -6,6 +6,13 @@ var dispatchRequest = require('./core/dispatchRequest');
var InterceptorManager = require('./core/InterceptorManager');
var axios = module.exports = function (config) {
// Allow for axios('example/url')
if (typeof config === 'string') {
config = {
url: config
};
}
config = utils.merge({
method: 'get',
headers: {},
+13
View File
@@ -9,6 +9,19 @@ describe('requests', function () {
jasmine.Ajax.uninstall();
});
it('should treat single string arg as url', function (done) {
var request;
axios('/foo');
setTimeout(function () {
request = jasmine.Ajax.requests.mostRecent();
expect(request.url).toBe('/foo');
done();
}, 0);
});
it('should make an http request', function (done) {
var request;