mirror of
https://github.com/tenrok/axios.git
synced 2026-06-20 20:00:40 +03:00
Rename axios.createNew to axios.create
This commit is contained in:
Vendored
+1
-1
@@ -17,7 +17,7 @@ declare module axios {
|
|||||||
|
|
||||||
interface AxiosStatic extends AxiosRequestMethods {
|
interface AxiosStatic extends AxiosRequestMethods {
|
||||||
(options: axios.RequestOptions): axios.Promise;
|
(options: axios.RequestOptions): axios.Promise;
|
||||||
createNew(defaultOptions?: axios.InstanceOptions): AxiosInstance;
|
create(defaultOptions?: axios.InstanceOptions): AxiosInstance;
|
||||||
all(iterable: any): axios.Promise;
|
all(iterable: any): axios.Promise;
|
||||||
spread(callback: any): axios.Promise;
|
spread(callback: any): axios.Promise;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -55,7 +55,7 @@ var defaultInstance = new Axios();
|
|||||||
|
|
||||||
var axios = module.exports = bind(Axios.prototype.request, defaultInstance);
|
var axios = module.exports = bind(Axios.prototype.request, defaultInstance);
|
||||||
|
|
||||||
axios.createNew = function (defaultConfig) {
|
axios.create = function (defaultConfig) {
|
||||||
return new Axios(defaultConfig);
|
return new Axios(defaultConfig);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -33,12 +33,12 @@ describe('static api', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should have factory method', function () {
|
it('should have factory method', function () {
|
||||||
expect(typeof axios.createNew).toEqual('function');
|
expect(typeof axios.create).toEqual('function');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('instance api', function () {
|
describe('instance api', function () {
|
||||||
var instance = axios.createNew();
|
var instance = axios.create();
|
||||||
|
|
||||||
it('should have request methods', function () {
|
it('should have request methods', function () {
|
||||||
expect(typeof instance.request).toEqual('function');
|
expect(typeof instance.request).toEqual('function');
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ describe('instance', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should make an http request', function (done) {
|
it('should make an http request', function (done) {
|
||||||
var instance = axios.createNew();
|
var instance = axios.create();
|
||||||
|
|
||||||
instance.request({
|
instance.request({
|
||||||
url: '/foo'
|
url: '/foo'
|
||||||
@@ -25,7 +25,7 @@ describe('instance', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should use instance options', function (done) {
|
it('should use instance options', function (done) {
|
||||||
var instance = axios.createNew({ timeout: 1000 });
|
var instance = axios.create({ timeout: 1000 });
|
||||||
|
|
||||||
instance.request({
|
instance.request({
|
||||||
url: '/foo'
|
url: '/foo'
|
||||||
|
|||||||
@@ -110,9 +110,9 @@ axios({
|
|||||||
xsrfHeaderName: 'X-XSRF-TOKEN' // default
|
xsrfHeaderName: 'X-XSRF-TOKEN' // default
|
||||||
});
|
});
|
||||||
|
|
||||||
var instance = axios.createNew();
|
var instance = axios.create();
|
||||||
|
|
||||||
axios.createNew({
|
axios.create({
|
||||||
transformRequest: (data) => {
|
transformRequest: (data) => {
|
||||||
return data.doSomething();
|
return data.doSomething();
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user