axios-rest-resource
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -23,21 +23,5 @@ import { AxiosPromise, AxiosRequestConfig } from 'axios'; | ||
} | ||
export declare type IResourceSchemaKeysDefault = 'create' | 'read' | 'readOne' | 'remove' | 'update'; | ||
export declare const resourceSchemaDefault: { | ||
create: { | ||
method: string; | ||
}; | ||
read: { | ||
method: string; | ||
}; | ||
readOne: { | ||
method: string; | ||
url: string; | ||
}; | ||
remove: { | ||
method: string; | ||
url: string; | ||
}; | ||
update: { | ||
method: string; | ||
url: string; | ||
}; | ||
[Key in IResourceSchemaKeysDefault]: IAPIMethodSchema; | ||
}; | ||
@@ -57,20 +41,7 @@ export interface IBuildParams { | ||
protected readonly _schemaDefault: { | ||
create: { | ||
method: string; | ||
}; | ||
read: { | ||
method: string; | ||
}; | ||
readOne: { | ||
method: string; | ||
url: string; | ||
}; | ||
remove: { | ||
method: string; | ||
url: string; | ||
}; | ||
update: { | ||
method: string; | ||
url: string; | ||
}; | ||
create: IAPIMethodSchema; | ||
read: IAPIMethodSchema; | ||
readOne: IAPIMethodSchema; | ||
remove: IAPIMethodSchema; | ||
update: IAPIMethodSchema; | ||
}; | ||
@@ -77,0 +48,0 @@ protected readonly _createAxiosResource: ICreateAxiosInstanceFromUrl; |
{ | ||
"name": "axios-rest-resource", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -34,3 +34,3 @@ # axios-rest-resource | ||
export const resourceBuilder = new ResourceBuilder({ | ||
baseUrl: "http://localhost:3000" | ||
baseURL: "http://localhost:3000" | ||
}); | ||
@@ -83,3 +83,3 @@ ``` | ||
export const resourceBuilder = new ResourceBuilder({ | ||
baseUrl: "http://localhost:3000", | ||
baseURL: "http://localhost:3000", | ||
interceptors: [myRequestInterceptor] | ||
@@ -109,3 +109,3 @@ }); | ||
export const resourceBuilder = new ResourceBuilder({ | ||
baseUrl: "http://localhost:3000", | ||
baseURL: "http://localhost:3000", | ||
interceptors: [interceptorAuthorizationToken] | ||
@@ -131,3 +131,3 @@ }); | ||
export const resourceBuilder = new ResourceBuilder({ | ||
baseUrl: "http://localhost:3000", | ||
baseURL: "http://localhost:3000", | ||
interceptors: [interceptorAuthorizationToken] | ||
@@ -158,3 +158,3 @@ }); | ||
export const resourceBuilder = new ResourceBuilder({ | ||
baseUrl: "http://localhost:3000", | ||
baseURL: "http://localhost:3000", | ||
interceptors: [interceptorAuthorizationToken, interceptorLogAction] | ||
@@ -166,3 +166,3 @@ }); | ||
You can pass a custom axios instance factory to ResourceBuilder. It's useful if you want to do something more with your axios instance but assign 'baseUrl' and add request inerceptors. | ||
You can pass a custom axios instance factory to ResourceBuilder. It's useful if you want to do something more with your axios instance but assign 'baseURL' and add request inerceptors. | ||
@@ -174,3 +174,3 @@ ```ts | ||
const createAxiosInstanceFromUrl = (resourceUrl: string): AxiosInstance => { | ||
const axiosInstance = axios.create({ baseUrl: "http://localshot:3000" }); | ||
const axiosInstance = axios.create({ baseURL: "http://localshot:3000" }); | ||
// This time we want to add response interceptors | ||
@@ -180,3 +180,3 @@ axiosInstance.interceptors.response.use(myResponeInterceptor); | ||
axiosInstance.interceptors.request.use(interceptorUrlFormatter); | ||
// Don't forget to append resourceUrl to baseUrl | ||
// Don't forget to append resourceUrl to baseURL | ||
axiosInstance.defaults.baseURL += resourceUrl; | ||
@@ -199,3 +199,3 @@ return axiosInstance; | ||
const createAxiosResource = createAxiosResourceFactory({ | ||
baseUrl: "http://localshot:3000" | ||
baseURL: "http://localshot:3000" | ||
}); | ||
@@ -202,0 +202,0 @@ const createAxiosInstanceFromUrl = (resourceUrl: string): AxiosInstance => { |
Sorry, the diff of this file is not supported yet
21127
175