Updated the RequestUtil.js
This commit is contained in:
parent
ae7914b9eb
commit
73f7014887
@ -1,8 +1,10 @@
|
||||
const URL = process.env.NODE_ENV === 'production' ? "https://tools-api.gnmyt.dev/" : "http://localhost:7182/";
|
||||
const DEFAULT_URL = process.env.NODE_ENV === 'production' ? "https://tools-api.gnmyt.dev/" : "http://localhost:7182/";
|
||||
|
||||
const getURL = () => localStorage.getItem("url") || DEFAULT_URL;
|
||||
|
||||
// Run a plain request with all default values
|
||||
export const request = (path, method = "GET", body = {}, headers = {}) => {
|
||||
return fetch(URL + path, {headers, method, body: method !== "GET" ? JSON.stringify(body) : undefined});
|
||||
return fetch(getURL() + path, {headers, method, body: method !== "GET" ? JSON.stringify(body) : undefined});
|
||||
}
|
||||
|
||||
// Run a GET request and get the json of the response
|
||||
|
Reference in New Issue
Block a user