Last active
January 17, 2019 15:30
-
-
Save t-book/10ad30b317ca1487d1d7ff77f9a34eab to your computer and use it in GitHub Desktop.
Check thumbs js fetch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function handleErrors(response) { | |
if (!response.ok) { | |
throw Error(response.statusText); | |
} | |
return response; | |
} | |
let thumbs = []; | |
fetch("http://master.demo.geonode.org/api/layers/") | |
.then(r => r.json()).then(data => { | |
thumbs = data.objects.map(x => [ x['title'],x['thumbnail_url'] ]) | |
}) | |
.then(data => { | |
for (let i in thumbs) { | |
fetch(thumbs[i][1]).then(handleErrors).then(function(response) { | |
console.log(`${i} OK: ${thumbs[i][0]}`); | |
}).catch(function(error) { | |
console.warn(`${error} ${thumbs[i][0]}`); | |
}); | |
} | |
}) | |
.catch(e => console.log(e)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment