Closed nounder closed 3 months ago
Similar to fetch, wretch should follow redirects and only then resolve the response.
wretch
uses fetch
under the hood.
const api = wretch("https://httpstat.us")
const cb = res => console.log({ status: res.status, redirected: res.redirected, url: res.url });
[301, 302, 303, 307, 308].forEach(code => {
api.url(`/${code}`).get().res(cb)
// { status: 200, redirected: true, url: 'https://httpstat.us/' }
})
Similar to fetch, wretch should follow redirects and only then resolve the response. Currently, without any user-defined error handling, it throws an error with unhelpful message of response body.