Created
November 27, 2018 11:24
-
-
Save dharavp/c2ff6845d13779cd44230286c53440c0 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
onRefresh() { | |
this.setState({ isRefreshing: true }); // true isRefreshing flag for enable pull to refresh indicator | |
const url = `https://api.stackexchange.com/2.2/users?page=1&order=desc&sort=reputation&site=stackoverflow`; | |
axios.get(url) | |
.then(res => { | |
let data = res.data.items | |
this.setState({ isRefreshing: false, data: data }) // false isRefreshing flag for disable pull to refresh indicator, and clear all data and store only first page data | |
}) | |
.catch(error => { | |
this.setState({ isRefreshing: false, error: 'Something just went wrong' }) // false isRefreshing flag for disable pull to refresh | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment