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