Provide access to change the API base url

This commit is contained in:
Adolfo Reyna
2025-02-22 00:00:59 -05:00
parent ad394a6f18
commit a1b2143337

10
API.js
View File

@@ -1,3 +1,4 @@
const baseUrl = "https://emiapi.reynafamily.com";
//const baseUrl = "http://localhost:3000";
@@ -6,7 +7,8 @@ let getCall = async (path = "", params = {}) => {
Object.keys(params).forEach(p => {
queryParams += p + "=" + params[p] + "&"
});
return fetch(baseUrl + path + queryParams, {
let localBaseUrl = global.baseUrl ?? baseUrl;
return fetch(localBaseUrl + path + queryParams, {
method: 'GET',
mode: 'cors',
credentials: 'include',
@@ -24,7 +26,8 @@ let deleteCall = async (path = "", params = {}) => {
Object.keys(params).forEach(p => {
queryParams += p + "=" + params[p] + "&"
});
return fetch(baseUrl + path + queryParams, {
let localBaseUrl = global.baseUrl ?? baseUrl;
return fetch(localBaseUrl + path + queryParams, {
method: 'DELETE',
mode: 'cors',
credentials: 'include',
@@ -38,7 +41,8 @@ let deleteCall = async (path = "", params = {}) => {
}
let postCall = async (path, params) => {
return fetch(baseUrl + path, {
let localBaseUrl = global.baseUrl ?? baseUrl;
return fetch(localBaseUrl + path, {
method: 'POST',
mode: 'cors',
credentials: 'include',