Provide access to change the API base url
This commit is contained in:
10
API.js
10
API.js
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user