Skip to content

Instantly share code, notes, and snippets.

@Manntrix
Last active April 25, 2020 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Manntrix/82bc0284fd2bd144044412a655b87717 to your computer and use it in GitHub Desktop.
Save Manntrix/82bc0284fd2bd144044412a655b87717 to your computer and use it in GitHub Desktop.
receivedData() {
axios
.get(`https://jsonplaceholder.typicode.com/photos`)
.then(res => {
const data = res.data;
const slice = data.slice(this.state.offset, this.state.offset + this.state.perPage)
const postData = slice.map(pd => <React.Fragment>
<p>{pd.title}</p>
<img src={pd.thumbnailUrl} alt=""/>
</React.Fragment>)
this.setState({
pageCount: Math.ceil(data.length / this.state.perPage),
postData
})
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment