return the last result

This commit is contained in:
Etienne Prothon 2020-06-15 14:48:22 +02:00
parent 4406b16455
commit 389d5fd426

View File

@ -40,7 +40,7 @@ async function fetch(cookieJars, url, options) {
if (wantFollow) {
options.redirect = 'manual'
}
const result = await _fetch(url, options);
let result = await _fetch(url, options);
// I cannot use headers.get() here because it joins the cookies to a string
cookies = result.headers[Object.getOwnPropertySymbols(result.headers)[0]]["set-cookie"];
if(cookies && cookieJars) {
@ -55,7 +55,7 @@ async function fetch(cookieJars, url, options) {
if (wantFollow && redirectStatus.has(result.status)) {
const location = result.headers.get('Location')
options.redirect = 'follow'
await fetch(cookieJars, location, options)
result = await fetch(cookieJars, location, options)
}
return result;
}