WA-521 Improved enhancedFetch returning error and data in a promise
This commit is contained in:
parent
03d632b755
commit
1518521dba
|
@ -12,8 +12,8 @@ export const enhancedFetch = async (url: string, errMsg: string) => {
|
||||||
|
|
||||||
const response = await fetch(url, sentData)
|
const response = await fetch(url, sentData)
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(errMsg)
|
return Promise.reject(new Error(errMsg))
|
||||||
}
|
}
|
||||||
|
|
||||||
return response.json()
|
return Promise.resolve(response.json())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue