Created
November 27, 2018 11:32
-
-
Save dharavp/d24e9d925b032a46cc33ab45863a8baf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
fetchUser(page) { | |
//stackexchange User API url | |
const url = `https://api.stackexchange.com/2.2/users?page=${page}&order=desc&sort=reputation&site=stackoverflow`; | |
this.setState({ loading: true }) | |
axios.get(url) | |
.then(res => { | |
let listData = this.state.data; | |
let data = listData.concat(res.data.items) . //concate list with response | |
this.setState({ loading: false, data: data }) | |
}) | |
.catch(error => { | |
this.setState({ loading: false, error: 'Something just went wrong' }) | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment