2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-08 17:22:34 +03:00

Correctly add response interceptors to interceptor chain (#4013)

This commit is contained in:
Julian Hollmann
2021-09-04 20:55:38 +02:00
committed by GitHub
parent c0c8761091
commit 83ae3830e4
2 changed files with 30 additions and 1 deletions
+29
View File
@@ -252,6 +252,35 @@ describe('interceptors', function () {
});
});
it('should add a response interceptor when request interceptor is defined', function (done) {
var response;
axios.interceptors.request.use(function (data) {
return data;
});
axios.interceptors.response.use(function (data) {
data.data = data.data + ' - modified by interceptor';
return data;
});
axios('/foo').then(function (data) {
response = data;
});
getAjaxRequest().then(function (request) {
request.respondWith({
status: 200,
responseText: 'OK'
});
setTimeout(function () {
expect(response.data).toBe('OK - modified by interceptor');
done();
}, 100);
});
});
it('should add a response interceptor that returns a new data object', function (done) {
var response;