I need to find a way when the request gets a 403 I can use if
before calling JSON with status and data. Only 403 returns HTML
const response = await fetch(
// Fetch info
).then((response) => {
if (!response.ok && response.status === 403) {
// Stuffs
throw new Error('Exception message'); // Raise error to stop the code
}
return response.json();
})
.then((data) => ({
// I need use status code again, and keep the if statement 403 on top.
status: response.status,
data,
}));