Skip to content

Instantly share code, notes, and snippets.

@johnthepink
Created April 18, 2016 04:30
Show Gist options
  • Save johnthepink/49259684645688213f6fd8456495d4af to your computer and use it in GitHub Desktop.
Save johnthepink/49259684645688213f6fd8456495d4af to your computer and use it in GitHub Desktop.
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