Skip to content

Instantly share code, notes, and snippets.

@vinitkumar
Created November 1, 2018 10:55
Show Gist options
  • Save vinitkumar/ce739beeab314508413a75a6a6916016 to your computer and use it in GitHub Desktop.
Save vinitkumar/ce739beeab314508413a75a6a6916016 to your computer and use it in GitHub Desktop.
getImages(URL) {
let allURLS = []
return fetch(URL)
.then((response) => { return response.json(); })
.then((json) => {
allURLS.push(json.results);
let newPhotoList = [...this.state.photoList, ...json.results]
this.setState({photoList: newPhotoList})
const nextURL = json.next;
if (!nextURL) {
return;
}
else {
this.getImages(nextURL);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment