mirror of
https://github.com/tenrok/axios.git
synced 2026-06-14 18:42:33 +03:00
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
var defaults = require('./defaults');
|
var defaults = require('./defaults');
|
||||||
var utils = require('./utils');
|
var utils = require('./utils');
|
||||||
var deprecatedMethod = require('./helpers/deprecatedMethod');
|
|
||||||
var dispatchRequest = require('./core/dispatchRequest');
|
var dispatchRequest = require('./core/dispatchRequest');
|
||||||
var InterceptorManager = require('./core/InterceptorManager');
|
var InterceptorManager = require('./core/InterceptorManager');
|
||||||
|
|
||||||
@@ -43,26 +42,6 @@ var axios = module.exports = function axios(config) {
|
|||||||
promise = promise.then(chain.shift(), chain.shift());
|
promise = promise.then(chain.shift(), chain.shift());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Provide alias for success
|
|
||||||
promise.success = function success(fn) {
|
|
||||||
deprecatedMethod('success', 'then', 'https://github.com/mzabriskie/axios/blob/master/README.md#response-api');
|
|
||||||
|
|
||||||
promise.then(function(response) {
|
|
||||||
fn(response.data, response.status, response.headers, response.config);
|
|
||||||
});
|
|
||||||
return promise;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Provide alias for error
|
|
||||||
promise.error = function error(fn) {
|
|
||||||
deprecatedMethod('error', 'catch', 'https://github.com/mzabriskie/axios/blob/master/README.md#response-api');
|
|
||||||
|
|
||||||
promise.then(null, function(response) {
|
|
||||||
fn(response.data, response.status, response.headers, response.config);
|
|
||||||
});
|
|
||||||
return promise;
|
|
||||||
};
|
|
||||||
|
|
||||||
return promise;
|
return promise;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,6 @@ describe('api', function () {
|
|||||||
|
|
||||||
expect(typeof promise.then).toEqual('function');
|
expect(typeof promise.then).toEqual('function');
|
||||||
expect(typeof promise.catch).toEqual('function');
|
expect(typeof promise.catch).toEqual('function');
|
||||||
expect(typeof promise.success).toEqual('function');
|
|
||||||
expect(typeof promise.error).toEqual('function');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should have defaults', function () {
|
it('should have defaults', function () {
|
||||||
|
|||||||
@@ -37,37 +37,6 @@ describe('promise', function () {
|
|||||||
}, 0);
|
}, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should provide verbose arguments to success', function (done) {
|
|
||||||
var request, data, status, headers, config;
|
|
||||||
|
|
||||||
axios({
|
|
||||||
url: '/foo'
|
|
||||||
}).success(function (d, s, h, c) {
|
|
||||||
data = d;
|
|
||||||
status = s;
|
|
||||||
headers = h;
|
|
||||||
config = c;
|
|
||||||
fulfilled = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
setTimeout(function () {
|
|
||||||
request = jasmine.Ajax.requests.mostRecent();
|
|
||||||
|
|
||||||
request.respondWith({
|
|
||||||
status: 200,
|
|
||||||
responseText: '{"hello":"world"}'
|
|
||||||
});
|
|
||||||
|
|
||||||
setTimeout(function () {
|
|
||||||
expect(data.hello).toEqual('world');
|
|
||||||
expect(status).toBe(200);
|
|
||||||
expect(headers['content-type']).toEqual('application/json');
|
|
||||||
expect(config.url).toEqual('/foo');
|
|
||||||
done();
|
|
||||||
}, 0);
|
|
||||||
}, 0);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should support all', function (done) {
|
it('should support all', function (done) {
|
||||||
var fulfilled = false;
|
var fulfilled = false;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user