Skip to content

Instantly share code, notes, and snippets.

@moisescastillo
Created August 14, 2020 04:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moisescastillo/15e6442570640636c84189cd8170554e to your computer and use it in GitHub Desktop.
Save moisescastillo/15e6442570640636c84189cd8170554e to your computer and use it in GitHub Desktop.
Javascript fetch example 01
fetch('https://jsonplaceholder.typicode.com/posts/')
.then(
function(response) {
if (response.status !== 200) {
console.log(response.status);
return;
}
response.json().then(function(data) {
data.forEach((value, index) => {
console.log(value.id);
console.log(value.title);
console.log(value.body);
console.log(value.userId);
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment