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

Fixing baseURL not working in interceptors (#950)

* Fixing baseURL not working in interceptors

* add test for  modify base URL in request interceptor
This commit is contained in:
Haven
2017-08-12 20:15:27 +08:00
committed by Rubén Norte
parent 6508280bbf
commit 2b8562694e
3 changed files with 25 additions and 7 deletions
+18
View File
@@ -252,4 +252,22 @@ describe('interceptors', function () {
done();
});
});
it('should modify base URL in request interceptor', function (done) {
var instance = axios.create({
baseURL: 'http://test.com/'
});
instance.interceptors.request.use(function (config) {
config.baseURL = 'http://rebase.com/';
return config;
});
instance.get('/foo');
getAjaxRequest().then(function (request) {
expect(request.url).toBe('http://rebase.com/foo');
done();
});
});
});