Skip to content

Instantly share code, notes, and snippets.

@vishwasnavadak
Last active November 18, 2018 13:00
Show Gist options
  • Save vishwasnavadak/12c74231376bdd66d697d12c9470dafb to your computer and use it in GitHub Desktop.
Save vishwasnavadak/12c74231376bdd66d697d12c9470dafb to your computer and use it in GitHub Desktop.
Fetch function to get data from AWS API-GATEWAY
export function fetchTodoList(){
var request = fetch('API-URL',{
method: 'GET',
headers:{
'Content-Type': 'application/json',
'x-api-key': 'API-KEY'
}
})
.then(response => response.json())
.then((data) => { return data; } )
.catch(error => console.log('Error while fetching:', error));
return ({
type:ActionTypes.FETCH_TODOLIST,
payload:request
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment