Update API to map destroy endpoint properly
This commit is contained in:
parent
c88e9be025
commit
54f9d3682b
1 changed files with 3 additions and 2 deletions
|
|
@ -9,6 +9,7 @@ type IdEndpoint = ({ id }: { id: string }) => Promise<AxiosResponse<any>>
|
||||||
type IdWithObjectEndpoint = ({ id, object }: { id: string, object: string }) => Promise<AxiosResponse<any>>
|
type IdWithObjectEndpoint = ({ id, object }: { id: string, object: string }) => Promise<AxiosResponse<any>>
|
||||||
type PostEndpoint = (object: {}, headers?: {}) => Promise<AxiosResponse<any>>
|
type PostEndpoint = (object: {}, headers?: {}) => Promise<AxiosResponse<any>>
|
||||||
type PutEndpoint = (id: string, object: {}, headers?: {}) => Promise<AxiosResponse<any>>
|
type PutEndpoint = (id: string, object: {}, headers?: {}) => Promise<AxiosResponse<any>>
|
||||||
|
type DestroyEndpoint = (id: string, headers?: {}) => Promise<AxiosResponse<any>>
|
||||||
|
|
||||||
interface EndpointMap {
|
interface EndpointMap {
|
||||||
getAll: CollectionEndpoint
|
getAll: CollectionEndpoint
|
||||||
|
|
@ -16,7 +17,7 @@ interface EndpointMap {
|
||||||
getOneWithObject: IdWithObjectEndpoint
|
getOneWithObject: IdWithObjectEndpoint
|
||||||
create: PostEndpoint
|
create: PostEndpoint
|
||||||
update: PutEndpoint
|
update: PutEndpoint
|
||||||
destroy: IdEndpoint
|
destroy: DestroyEndpoint
|
||||||
}
|
}
|
||||||
|
|
||||||
class Api {
|
class Api {
|
||||||
|
|
@ -45,7 +46,7 @@ class Api {
|
||||||
getOneWithObject: ({ id, object }: { id: string, object: string }) => axios.get(`${resourceUrl}/${id}/${object}`),
|
getOneWithObject: ({ id, object }: { id: string, object: string }) => axios.get(`${resourceUrl}/${id}/${object}`),
|
||||||
create: (object: {}, headers?: {}) => axios.post(resourceUrl, object, headers),
|
create: (object: {}, headers?: {}) => axios.post(resourceUrl, object, headers),
|
||||||
update: (id: string, object: {}, headers?: {}) => axios.put(`${resourceUrl}/${id}`, object, headers),
|
update: (id: string, object: {}, headers?: {}) => axios.put(`${resourceUrl}/${id}`, object, headers),
|
||||||
destroy: ({ id }: { id: string }) => axios.delete(`${resourceUrl}/${id}`)
|
destroy: (id: string, headers?: {}) => axios.delete(`${resourceUrl}/${id}`, headers)
|
||||||
} as EndpointMap
|
} as EndpointMap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue