提交 219a1c29 编写于 作者: M mzabriskie

Supporting a fetch like API

上级 b92fa960
......@@ -6,11 +6,11 @@ var dispatchRequest = require('./core/dispatchRequest');
var InterceptorManager = require('./core/InterceptorManager');
var axios = module.exports = function (config) {
// Allow for axios('example/url')
// Allow for axios('example/url'[, config]) a la fetch API
if (typeof config === 'string') {
config = {
url: config
};
config = utils.merge({
url: arguments[0]
}, arguments[1]);
}
config = utils.merge({
......
......@@ -18,6 +18,23 @@ describe('requests', function () {
request = jasmine.Ajax.requests.mostRecent();
expect(request.url).toBe('/foo');
expect(request.method).toBe('GET');
done();
}, 0);
});
it('should allow string arg as url, and config arg', function (done) {
var request;
axios('/foo', {
method: 'POST'
});
setTimeout(function () {
request = jasmine.Ajax.requests.mostRecent();
expect(request.url).toBe('/foo');
expect(request.method).toBe('POST');
done();
}, 0);
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册