For some reason I cannot really push all the failed/undetectable urls (pstart is a link, tmp is the directory name) into an array after the fetch fails on a link. I even added in an additional catch after the response! Can someone please help me out with figuring out how to get around this?
This is a fetch to check whether a website (cross-domain) exists or not. It would come back as a failed connection when I use console.log(error)
but it wouldn't treat it the way it turned out.
var failed = []
fetch((pstart + tmp), {
method: 'POST',
mode: 'no-cors',
credentials: 'include',
referrerPolicy: 'no-referrer'
}).then((response) => {
if (!response.ok) {
failed[i] = tmp
console.log("Couldn't fetch.");
}
})
.catch((error) => {
failed[i] = tmp
})
// Check for connections, clones, and fails
if ((failed.includes(tmp))||(l.includes(tmp))){
i -= 1
} else {
l.push(tmp);
}
Aucun commentaire:
Enregistrer un commentaire