From e26e337c3985c16b9324852ad4da00bbd462a076 Mon Sep 17 00:00:00 2001 From: Tanishq Manuja Date: Fri, 17 Jan 2025 18:01:25 +0530 Subject: [PATCH] fix: impl of axios client for testing --- packages/tests/axios.ts | 43 +++++++++-------------------------------- 1 file changed, 9 insertions(+), 34 deletions(-) diff --git a/packages/tests/axios.ts b/packages/tests/axios.ts index 5d38e6e..bdd1f97 100644 --- a/packages/tests/axios.ts +++ b/packages/tests/axios.ts @@ -1,35 +1,10 @@ import axios2 from "axios" -export const axios = { - async post, D = any>(url: string, data?: D, config?: axios2.AxiosRequestConfig): Promise { - try { - const res = await axios2.post(url, data, config) - return res - } catch(e: any) { - return e.response - } - }, - get: async (...args: any) => { - try { - const res = await axios2.get(...args) - return res - } catch(e) { - return e.response - } - }, - put: async (...args: any) => { - try { - const res = await axios2.put(...args) - return res - } catch(e) { - return e.response - } - }, - delete: async (...args: any) => { - try { - const res = await axios2.delete(...args) - return res - } catch(e) { - return e.response - } - }, -} \ No newline at end of file + +const client = axios2.create(); + +client.interceptors.response.use( + (response) => response, + (error) => error.response +); + +export const axios = client; \ No newline at end of file