mirror of
https://github.com/oceanprotocol/docs.git
synced 2024-11-26 19:49:26 +01:00
properly cancel axios requests
This commit is contained in:
parent
a900be9992
commit
e7a871a080
@ -116,6 +116,15 @@ class Numbers extends PureComponent {
|
||||
}
|
||||
|
||||
url = 'https://oceanprotocol-github.now.sh'
|
||||
signal = axios.CancelToken.source()
|
||||
|
||||
componentDidMount() {
|
||||
this.fetchNumbers()
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.signal.cancel()
|
||||
}
|
||||
|
||||
fetchNumbers = async () => {
|
||||
try {
|
||||
@ -147,14 +156,14 @@ class Numbers extends PureComponent {
|
||||
this.setState({ stars })
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error) // eslint-disable-line no-console
|
||||
if (axios.isCancel(error)) {
|
||||
return null
|
||||
} else {
|
||||
console.log(error.message) // eslint-disable-line no-console
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.fetchNumbers()
|
||||
}
|
||||
|
||||
render() {
|
||||
const { url } = this.props
|
||||
const { forks, stars } = this.state
|
||||
|
Loading…
Reference in New Issue
Block a user