Skip to content

Instantly share code, notes, and snippets.

@vishwasnavadak
Created November 18, 2018 16:10
Show Gist options
  • Save vishwasnavadak/c4dd9f7a09f52791be2cf904295336c3 to your computer and use it in GitHub Desktop.
Save vishwasnavadak/c4dd9f7a09f52791be2cf904295336c3 to your computer and use it in GitHub Desktop.

Revisions

  1. vishwasnavadak created this gist Nov 18, 2018.
    16 changes: 16 additions & 0 deletions addItemAPIGateway.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    export function addTodo(item){
    var request = fetch(`API-URL?desc=${item}`,{
    method: 'POST',
    headers:{
    'Content-Type': 'application/json',
    'x-api-key': 'API-KEY'
    }
    })
    .then(response => response.json())
    .then((data) => { return data; } )
    .catch(error => console.log('Error while adding:', error));
    return ({
    type:ActionTypes.ADD_TODO,
    payload:request
    })
    }