I'm trying to get async await to work without try/catch
return await fetch(url, options)
.then(res => res.json())
.catch(err => {
throw new Error(err)
})
Here is how I make the call:
const response = await makeApiRequest('/reset', {
password: password1,
code
}, {
noauth: true
}).catch(err => {
debugger;
msg = err.message;
});
if (response) {
navigateTo('/');
}
The problem is none of the catch blocks are working. The code is expired and serving a 401.
return await fetchshould just bereturn fetch- in an async function you don't need toreturn awaita promise.then(res => res.ok ? res.json() : Promise.reject(res.statusText))... res.ok is only true for response.status = 200->299