Skip to content

Instantly share code, notes, and snippets.

@vishwasnavadak
Last active November 18, 2018 13:00
Show Gist options
  • Select an option

  • Save vishwasnavadak/12c74231376bdd66d697d12c9470dafb to your computer and use it in GitHub Desktop.

Select an option

Save vishwasnavadak/12c74231376bdd66d697d12c9470dafb to your computer and use it in GitHub Desktop.

Revisions

  1. vishwasnavadak revised this gist Nov 18, 2018. No changes.
  2. vishwasnavadak created this gist Nov 18, 2018.
    16 changes: 16 additions & 0 deletions fetchAPIGateway.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    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
    })
    }