From 54f9d3682b35d4ac487113add2ef7fe284f2f787 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Wed, 23 Feb 2022 16:42:56 -0800 Subject: [PATCH] Update API to map destroy endpoint properly --- utils/api.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/utils/api.tsx b/utils/api.tsx index f1cc9c85..e1d02c37 100644 --- a/utils/api.tsx +++ b/utils/api.tsx @@ -9,6 +9,7 @@ type IdEndpoint = ({ id }: { id: string }) => Promise> type IdWithObjectEndpoint = ({ id, object }: { id: string, object: string }) => Promise> type PostEndpoint = (object: {}, headers?: {}) => Promise> type PutEndpoint = (id: string, object: {}, headers?: {}) => Promise> +type DestroyEndpoint = (id: string, headers?: {}) => Promise> interface EndpointMap { getAll: CollectionEndpoint @@ -16,7 +17,7 @@ interface EndpointMap { getOneWithObject: IdWithObjectEndpoint create: PostEndpoint update: PutEndpoint - destroy: IdEndpoint + destroy: DestroyEndpoint } class Api { @@ -45,7 +46,7 @@ class Api { getOneWithObject: ({ id, object }: { id: string, object: string }) => axios.get(`${resourceUrl}/${id}/${object}`), create: (object: {}, headers?: {}) => axios.post(resourceUrl, 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 }