From 51ed0bc8b6902c47a754e2abb89259088207be95 Mon Sep 17 00:00:00 2001 From: mudabbir-ahmad Date: Mon, 6 Apr 2026 02:20:43 +0100 Subject: [PATCH] Update API base URL for local development; implement fetch timeout handling for improved request management --- src/components/API/API.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/components/API/API.js b/src/components/API/API.js index 1207822..761588f 100644 --- a/src/components/API/API.js +++ b/src/components/API/API.js @@ -2,7 +2,7 @@ import Constants from 'expo-constants'; const getBaseUrl = () => { const host = Constants.expoGoConfig?.debuggerHost; - if (host) return `http://${host.split(':')[0]}:3000`; + if (host) return 'http://192.168.8.100:3000'; return 'http://api.bobby.ip-ddns.com'; }; @@ -29,7 +29,10 @@ const callFetch = async (endpoint, method, dataObj = null) => { // Call the fetch and process the return try { let result = null; - const response = await fetch(endpoint, requestObj); + const controller = new AbortController(); + const timeoutId = setTimeout(() => controller.abort(), 10000); + const response = await fetch(endpoint, {...requestObj, signal: controller.signal}); + clearTimeout(timeoutId); if (response.status !== 204) result = await response.json(); return response.status >= 200 && response.status < 300 ? {isSuccess: true, result}