Update api.tsx
Allow headers
This commit is contained in:
parent
2b78605ac9
commit
b2e62ae89e
1 changed files with 3 additions and 3 deletions
|
|
@ -6,7 +6,7 @@ interface Entity {
|
||||||
|
|
||||||
type CollectionEndpoint = ({ query }: { query: AxiosRequestConfig }) => Promise<AxiosResponse<any>>
|
type CollectionEndpoint = ({ query }: { query: AxiosRequestConfig }) => Promise<AxiosResponse<any>>
|
||||||
type IdEndpoint = ({ id }: { id: string }) => Promise<AxiosResponse<any>>
|
type IdEndpoint = ({ id }: { id: string }) => Promise<AxiosResponse<any>>
|
||||||
type PostEndpoint = (object: {}) => Promise<AxiosResponse<any>>
|
type PostEndpoint = (object: {}, headers?: {}) => Promise<AxiosResponse<any>>
|
||||||
|
|
||||||
interface EndpointMap {
|
interface EndpointMap {
|
||||||
getAll: CollectionEndpoint
|
getAll: CollectionEndpoint
|
||||||
|
|
@ -39,8 +39,8 @@ class Api {
|
||||||
return {
|
return {
|
||||||
getAll: ({ query }: { query: AxiosRequestConfig }) => axios.get(resourceUrl, { params: { query }}),
|
getAll: ({ query }: { query: AxiosRequestConfig }) => axios.get(resourceUrl, { params: { query }}),
|
||||||
getOne: ({ id }: { id: string }) => axios.get(`${resourceUrl}/${id}`),
|
getOne: ({ id }: { id: string }) => axios.get(`${resourceUrl}/${id}`),
|
||||||
create: (object: {}) => axios.post(resourceUrl, object),
|
create: (object: {}, headers?: {}) => axios.post(resourceUrl, object, headers),
|
||||||
update: (object: {}) => axios.put(resourceUrl, object),
|
update: (object: {}, headers?: {}) => axios.put(resourceUrl, object, headers),
|
||||||
destroy: ({ id }: { id: string }) => axios.delete(`${resourceUrl}/${id}`)
|
destroy: ({ id }: { id: string }) => axios.delete(`${resourceUrl}/${id}`)
|
||||||
} as EndpointMap
|
} as EndpointMap
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue