From 93fb30a7bbf59303c30f6f20d0d38f39a00e9ba3 Mon Sep 17 00:00:00 2001 From: Shirish Date: Wed, 8 Apr 2026 18:32:52 +0100 Subject: [PATCH] api test changed default api calll --- package-lock.json | 19 +++++++++++++++ src/components/API/API.js | 51 +++++++++++++++++++-------------------- 2 files changed, 44 insertions(+), 26 deletions(-) diff --git a/package-lock.json b/package-lock.json index 952e587..5101718 100644 --- a/package-lock.json +++ b/package-lock.json @@ -77,6 +77,7 @@ "version": "7.29.0", "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.29.0.tgz", "integrity": "sha512-CGOfOJqWjg2qW/Mb6zNsDm+u5vFQ8DxXfbM09z69p5Z6+mE1ikP2jUXw+j42Pf1XTYED2Rni5f95npYeuwMDQA==", + "peer": true, "dependencies": { "@babel/code-frame": "^7.29.0", "@babel/generator": "^7.29.0", @@ -1364,6 +1365,7 @@ "version": "7.28.6", "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.28.6.tgz", "integrity": "sha512-05WQkdpL9COIMz4LjTxGpPNCdlpyimKppYNoJ5Di5EUObifl8t4tuLuUBBZEpoLYOmfvIWrsp9fCl0HoPRVTdA==", + "peer": true, "engines": { "node": ">=6.9.0" } @@ -2627,6 +2629,7 @@ "resolved": "https://registry.npmjs.org/@react-navigation/native/-/native-7.2.2.tgz", "integrity": "sha512-kem1Ko2BcbAjmbQIv66dNmr6EtfDut3QU0qjsVhMnLLhktwyXb6FzZYp8gTrUb6AvkAbaJoi+BF5Pl55pAUa5w==", "license": "MIT", + "peer": true, "dependencies": { "@react-navigation/core": "^7.17.2", "escape-string-regexp": "^4.0.0", @@ -2867,6 +2870,7 @@ "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.57.0.tgz", "integrity": "sha512-XZzOmihLIr8AD1b9hL9ccNMzEMWt/dE2u7NyTY9jJG6YNiNthaD5XtUHVF2uCXZ15ng+z2hT3MVuxnUYhq6k1g==", "dev": true, + "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.57.0", "@typescript-eslint/types": "8.57.0", @@ -3415,6 +3419,7 @@ "version": "8.16.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.16.0.tgz", "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==", + "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -4043,6 +4048,7 @@ "url": "https://github.com/sponsors/ai" } ], + "peer": true, "dependencies": { "baseline-browser-mapping": "^2.9.0", "caniuse-lite": "^1.0.30001759", @@ -4927,6 +4933,7 @@ "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.39.4.tgz", "integrity": "sha512-XoMjdBOwe/esVgEvLmNsD3IRHkm7fbKIUGvrleloJXUZgDHig2IPWNniv+GwjyJXzuNqVjlr5+4yVUZjycJwfQ==", "dev": true, + "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.1", @@ -5114,6 +5121,7 @@ "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.32.0.tgz", "integrity": "sha512-whOE1HFo/qJDyX4SnXzP4N6zOWn79WhnCUY/iDR0mPfQZO8wcYE4JClzI2oZrhBnnMUCBCHZhO6VQyoBU95mZA==", "dev": true, + "peer": true, "dependencies": { "@rtsao/scc": "^1.1.0", "array-includes": "^3.1.9", @@ -5337,6 +5345,7 @@ "version": "54.0.33", "resolved": "https://registry.npmjs.org/expo/-/expo-54.0.33.tgz", "integrity": "sha512-3yOEfAKqo+gqHcV8vKcnq0uA5zxlohnhA3fu4G43likN8ct5ZZ3LjAh9wDdKteEkoad3tFPvwxmXW711S5OHUw==", + "peer": true, "dependencies": { "@babel/runtime": "^7.20.0", "@expo/cli": "54.0.23", @@ -5424,6 +5433,7 @@ "version": "14.0.11", "resolved": "https://registry.npmjs.org/expo-font/-/expo-font-14.0.11.tgz", "integrity": "sha512-ga0q61ny4s/kr4k8JX9hVH69exVSIfcIc19+qZ7gt71Mqtm7xy2c6kwsPTCyhBW2Ro5yXTT8EaZOpuRi35rHbg==", + "peer": true, "dependencies": { "fontfaceobserver": "^2.1.0" }, @@ -8941,6 +8951,7 @@ "version": "19.1.0", "resolved": "https://registry.npmjs.org/react/-/react-19.1.0.tgz", "integrity": "sha512-FS+XFBNvn3GTAWq26joslQgWNoFu08F4kl0J4CgdNKADkdSGXQyTCnKteIAJy96Br6YbpEU1LSzV5dYtjMkMDg==", + "peer": true, "engines": { "node": ">=0.10.0" } @@ -8958,6 +8969,7 @@ "version": "19.1.0", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.1.0.tgz", "integrity": "sha512-Xs1hdnE+DyKgeHJeJznQmYMIBG3TKIHJJT95Q58nHLSrElKlGQqDTR2HQ9fx5CN/Gk6Vh/kupBTDLU11/nDk/g==", + "peer": true, "dependencies": { "scheduler": "^0.26.0" }, @@ -8986,6 +8998,7 @@ "version": "0.81.5", "resolved": "https://registry.npmjs.org/react-native/-/react-native-0.81.5.tgz", "integrity": "sha512-1w+/oSjEXZjMqsIvmkCRsOc8UBYv163bTWKTI8+1mxztvQPhCRYGTvZ/PL1w16xXHneIj/SLGfxWg2GWN2uexw==", + "peer": true, "dependencies": { "@jest/create-cache-key-function": "^29.7.0", "@react-native/assets-registry": "0.81.5", @@ -9113,6 +9126,7 @@ "version": "5.6.2", "resolved": "https://registry.npmjs.org/react-native-safe-area-context/-/react-native-safe-area-context-5.6.2.tgz", "integrity": "sha512-4XGqMNj5qjUTYywJqpdWZ9IG8jgkS3h06sfVjfw5yZQZfWnRFXczi0GnYyFyCc2EBps/qFmoCH8fez//WumdVg==", + "peer": true, "peerDependencies": { "react": "*", "react-native": "*" @@ -9122,6 +9136,7 @@ "version": "4.16.0", "resolved": "https://registry.npmjs.org/react-native-screens/-/react-native-screens-4.16.0.tgz", "integrity": "sha512-yIAyh7F/9uWkOzCi1/2FqvNvK6Wb9Y1+Kzn16SuGfN9YFJDTbwlzGRvePCNTOX0recpLQF3kc2FmvMUhyTCH1Q==", + "peer": true, "dependencies": { "react-freeze": "^1.0.0", "react-native-is-edge-to-edge": "^1.2.1", @@ -9136,6 +9151,7 @@ "version": "0.21.2", "resolved": "https://registry.npmjs.org/react-native-web/-/react-native-web-0.21.2.tgz", "integrity": "sha512-SO2t9/17zM4iEnFvlu2DA9jqNbzNhoUP+AItkoCOyFmDMOhUnBBznBDCYN92fGdfAkfQlWzPoez6+zLxFNsZEg==", + "peer": true, "dependencies": { "@babel/runtime": "^7.18.6", "@react-native/normalize-colors": "^0.74.1", @@ -9165,6 +9181,7 @@ "version": "0.5.1", "resolved": "https://registry.npmjs.org/react-native-worklets/-/react-native-worklets-0.5.1.tgz", "integrity": "sha512-lJG6Uk9YuojjEX/tQrCbcbmpdLCSFxDK1rJlkDhgqkVi1KZzG7cdcBFQRqyNOOzR9Y0CXNuldmtWTGOyM0k0+w==", + "peer": true, "dependencies": { "@babel/plugin-transform-arrow-functions": "^7.0.0-0", "@babel/plugin-transform-class-properties": "^7.0.0-0", @@ -9268,6 +9285,7 @@ "version": "0.14.2", "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.14.2.tgz", "integrity": "sha512-jCvmsr+1IUSMUyzOkRcvnVbX3ZYC6g9TDrDbFuFmRDq7PD4yaGbLKNQL6k2jnArV8hjYxh7hVhAZB6s9HDGpZA==", + "peer": true, "engines": { "node": ">=0.10.0" } @@ -10385,6 +10403,7 @@ "version": "4.0.3", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", + "peer": true, "engines": { "node": ">=12" }, diff --git a/src/components/API/API.js b/src/components/API/API.js index 1275d4a..177eb7e 100644 --- a/src/components/API/API.js +++ b/src/components/API/API.js @@ -1,34 +1,33 @@ -//export const API_BASE_URL = 'http://api.bobby.ip-ddns.com'; // For actual use -export const API_BASE_URL = 'http://192.168.8.100:3000'; // Home network for mudabbir since, server is on my home network and router dont do loopback!!! +export const API_BASE_URL = "http://api.bobby.ip-ddns.com"; // For actual use +//export const API_BASE_URL = 'http://192.168.8.100:3000'; // Home network for mudabbir since, server is on my home network and router dont do loopback!!! const API = {}; -API.get = (endpoint) => callFetch(endpoint, 'GET'); -API.post = (endpoint, data) => callFetch(endpoint, 'POST', data); -API.put = (endpoint, data) => callFetch(endpoint, 'PUT', data); -API.delete = (endpoint) => callFetch(endpoint, 'DELETE'); +API.get = (endpoint) => callFetch(endpoint, "GET"); +API.post = (endpoint, data) => callFetch(endpoint, "POST", data); +API.put = (endpoint, data) => callFetch(endpoint, "PUT", data); +API.delete = (endpoint) => callFetch(endpoint, "DELETE"); export default API; const callFetch = async (endpoint, method, dataObj = null) => { - // Build request object - let requestObj = {method: method}; // GET, POST, PUT or DELETE - if (dataObj) - requestObj = { - ...requestObj, - headers: {'Content-type': 'application/json'}, - body: JSON.stringify(dataObj), - }; + // Build request object + let requestObj = { method: method }; // GET, POST, PUT or DELETE + if (dataObj) + requestObj = { + ...requestObj, + headers: { "Content-type": "application/json" }, + body: JSON.stringify(dataObj), + }; - // Call the fetch and process the return - try { - let result = null; - const response = await fetch(endpoint, requestObj); - if (response.status !== 204) result = await response.json(); - return response.status >= 200 && response.status < 300 - ? {isSuccess: true, result} - : {isSuccess: false, message: `${result.message}`}; - } catch (error) { - return {isSuccess: false, message: error.message}; - } + // Call the fetch and process the return + try { + let result = null; + const response = await fetch(endpoint, requestObj); + if (response.status !== 204) result = await response.json(); + return response.status >= 200 && response.status < 300 + ? { isSuccess: true, result } + : { isSuccess: false, message: `${result.message}` }; + } catch (error) { + return { isSuccess: false, message: error.message }; + } }; -