From b2e62ae89e3eb5ded64f4486566a0bafd848e71e Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Sat, 26 Sep 2020 10:51:30 -0700 Subject: [PATCH] Update api.tsx Allow headers --- src/utils/api.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/api.tsx b/src/utils/api.tsx index e829180d..9f63b81b 100644 --- a/src/utils/api.tsx +++ b/src/utils/api.tsx @@ -6,7 +6,7 @@ interface Entity { type CollectionEndpoint = ({ query }: { query: AxiosRequestConfig }) => Promise> type IdEndpoint = ({ id }: { id: string }) => Promise> -type PostEndpoint = (object: {}) => Promise> +type PostEndpoint = (object: {}, headers?: {}) => Promise> interface EndpointMap { getAll: CollectionEndpoint @@ -39,8 +39,8 @@ class Api { return { getAll: ({ query }: { query: AxiosRequestConfig }) => axios.get(resourceUrl, { params: { query }}), getOne: ({ id }: { id: string }) => axios.get(`${resourceUrl}/${id}`), - create: (object: {}) => axios.post(resourceUrl, object), - update: (object: {}) => axios.put(resourceUrl, object), + create: (object: {}, headers?: {}) => axios.post(resourceUrl, object, headers), + update: (object: {}, headers?: {}) => axios.put(resourceUrl, object, headers), destroy: ({ id }: { id: string }) => axios.delete(`${resourceUrl}/${id}`) } as EndpointMap }