mirror of
https://github.com/owncast/owncast.git
synced 2024-11-26 06:46:01 +03:00
Return the error message instead of the http status code
This commit is contained in:
parent
a2ed01b088
commit
745ee8cced
1 changed files with 3 additions and 2 deletions
|
@ -99,11 +99,12 @@ export async function fetchData(url: string, options?: FetchOptions) {
|
|||
|
||||
try {
|
||||
const response = await fetch(url, requestOptions);
|
||||
const json = await response.json();
|
||||
|
||||
if (!response.ok) {
|
||||
const message = `An error has occured: ${response.status}`;
|
||||
const message = json.message || `An error has occurred: ${response.status}`;
|
||||
throw new Error(message);
|
||||
}
|
||||
const json = await response.json();
|
||||
return json;
|
||||
} catch (error) {
|
||||
return error;
|
||||
|
|
Loading…
Reference in a new issue