Fixed a bug in the RequestUtil.js
This commit is contained in:
parent
130f53ac18
commit
e0a45cf338
@ -9,9 +9,13 @@ export const request = async (url, method, body, headers) => {
|
|||||||
|
|
||||||
if (response.status === 401) throw new Error("Unauthorized");
|
if (response.status === 401) throw new Error("Unauthorized");
|
||||||
|
|
||||||
|
const data = await response.json();
|
||||||
|
|
||||||
|
if (data.code >= 300) throw new Error(data.message);
|
||||||
|
|
||||||
if (!response.ok) throw new Error(await response.text());
|
if (!response.ok) throw new Error(await response.text());
|
||||||
|
|
||||||
return await response.json();
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const sessionRequest = (url, method, token, body) => {
|
export const sessionRequest = (url, method, token, body) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user