Created
November 18, 2018 16:10
-
-
Save vishwasnavadak/c4dd9f7a09f52791be2cf904295336c3 to your computer and use it in GitHub Desktop.
Add function to send data to AWS API-GATEWAY
This file contains 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
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 | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment