check json format
This commit is contained in:
parent
4a5041a65e
commit
d1091e570b
@ -5,7 +5,7 @@ const LOCAL = "http://localhost:8099";
|
|||||||
const DEV = "https://dev.bro-js.ru";
|
const DEV = "https://dev.bro-js.ru";
|
||||||
const SERVER = "";
|
const SERVER = "";
|
||||||
|
|
||||||
export const BASE_API_URL = DEV + getConfigValue("enterfront.api");
|
export const BASE_API_URL = LOCAL + getConfigValue("enterfront.api");
|
||||||
|
|
||||||
// fetch(`${BASE_API_URL}/books/list`)
|
// fetch(`${BASE_API_URL}/books/list`)
|
||||||
|
|
||||||
@ -21,18 +21,18 @@ export async function post(path, body) {
|
|||||||
body: JSON.stringify(body)
|
body: JSON.stringify(body)
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('Data from API:', res);
|
const data = JSON.parse(await res.text());
|
||||||
|
|
||||||
|
console.log("Data from API:", data)
|
||||||
|
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
const data = await res.json();
|
|
||||||
console.log("Received post:", data);
|
console.log("Received post:", data);
|
||||||
|
|
||||||
return {ok: true, data: data};
|
return {ok: true, data: data};
|
||||||
} else {
|
} else {
|
||||||
const errorData = await res.json();
|
console.log("Error during post:", data.message);
|
||||||
console.log("Error during post:", errorData.message);
|
|
||||||
|
|
||||||
return {ok: false, data: errorData};
|
return {ok: false, data: data};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user