Skip to content

Instantly share code, notes, and snippets.

@mariusz-blaszczak
Created March 17, 2017 18:29
Show Gist options
  • Save mariusz-blaszczak/f52b8bd9c8f588a285ae9de80ca6843b to your computer and use it in GitHub Desktop.
Save mariusz-blaszczak/f52b8bd9c8f588a285ae9de80ca6843b to your computer and use it in GitHub Desktop.
const sumNumbersWithApi = (a, b) => {
const url = `https://stark-escarpment-75299.herokuapp.com/?a=${a}&b=${b}`;
return fetch(url)
.then(response => response.json())
.then(response => response['response'])
.then(response => parseInt(response))
.catch((error) => {
console.log("there was error:", error.message);
});
};
const putInConsole = (response) => {
console.log(response)
};
sumNumbersWithApi(1,2)
.then(response => sumNumbersWithApi(3, response))
.then(response => sumNumbersWithApi(3, response))
.then(response => sumNumbersWithApi(3, response))
.then(putInConsole);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment