From f978c6f7d7c412e5bfb6b281a746012d0ab7f8ac Mon Sep 17 00:00:00 2001 From: Mo Tarbin Date: Sat, 7 Feb 2026 23:26:55 -0500 Subject: [PATCH] enhance Fetch function to handle different HTTP methods in apiClient --- src/utils/Fetcher.jsx | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/utils/Fetcher.jsx b/src/utils/Fetcher.jsx index 4dae85b..4124c92 100644 --- a/src/utils/Fetcher.jsx +++ b/src/utils/Fetcher.jsx @@ -2,8 +2,19 @@ import { apiClient } from './ApiClient' // Migration helpers to maintain compatibility with existing code const Fetch = async (endpoint, options = {}) => { - const response = await apiClient.request(endpoint, options) - return response + // base on options.method, call the appropriate method on apiClient: + switch (options.method) { + case 'GET': + return apiClient.get(endpoint, options) + case 'POST': + return apiClient.post(endpoint, options.body, options) + case 'PUT': + return apiClient.put(endpoint, options.body, options) + case 'DELETE': + return apiClient.delete(endpoint, options) + default: + return apiClient.request(endpoint, options) + } } const HEADERS = () => { @@ -1007,5 +1018,6 @@ export { UpdateThingState, UpdateTimeSession, UpdateUserDetails, - VerifyMFA, + VerifyMFA } +