Created
April 18, 2016 04:30
-
-
Save johnthepink/49259684645688213f6fd8456495d4af 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
getDataOptions = () => { | |
return { | |
headers: { | |
'User-Agent': 'app', | |
'Authorization': `key=${this.state.api_key}`, | |
}, | |
timeout: 5000 | |
}; | |
} | |
fetchData = () => { | |
this.setState({ | |
user: null | |
}); | |
fetch(REQUEST_URL, this.getDataOptions()) | |
.then((response) => response.json()) | |
.then((responseData) => { | |
this.setState({ | |
user: responseData | |
}) | |
}) | |
.catch((error) => { | |
console.log("Error in fetch"); | |
}) | |
.done(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment