Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function customFetch(requestInfo, init) {
const response = await fetch(requestInfo, init)
const res = response.clone()
if (!res.ok) {
const body = await res.json()
if (response.status === 404) {
throwServerError(res, body, 'Not found error')
}
if (response.status === 500) {
throwServerError(res, body, `Internal error: ${body.Message}`)
}
}
return response
}
export async function customFetch(requestInfo, init) {
const response = await fetch(requestInfo, init)
const res = response.clone()
if (!res.ok) {
const body = await res.json()
if (response.status === 404) {
throwServerError(res, body, 'Not found error')
}
if (response.status === 500) {
throwServerError(res, body, `Internal error: ${body.Message}`)
}
}
return response
}