change name action for api

This commit is contained in:
Nikolai Petukhov
2024-10-03 22:35:39 +03:00
parent 6bea0428f4
commit 8d0fadc906
12 changed files with 123 additions and 70 deletions

View File

@@ -10,10 +10,13 @@ export const BASE_API_URL = DEV + getConfigValue("enterfront.api");
// fetch(`${BASE_API_URL}/books/list`)
export async function post(path, body) {
const token = localStorage.getItem('token');
const res = await fetch(`${BASE_API_URL}${path}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": token ? `Bearer ${token}` : undefined
},
body: JSON.stringify(body)
});
@@ -32,8 +35,13 @@ export async function post(path, body) {
}
export async function get(path){
const token = localStorage.getItem('token');
const res = await fetch(`${BASE_API_URL}${path}`, {
method: "GET"
method: "GET",
headers: {
"Authorization": token ? `Bearer ${token}` : undefined
}
});
if (res.status === 200) {