Return to Snippet

Revision: 72340
at July 24, 2017 06:18 by sudhiakki


Initial Code
fetch('products.json') // some API path
// as response comes in form of string we use response.json to parse it in JSON 
    .then(function(response) { return response.json(); })
// parse JSON in form of parameter innext line
    .then(function(json) {
      for(var i = 0; i < json.products.length; i++) {
        console.log(json.products[i])
      }
    });

Initial URL


Initial Description
Get JSON data from server via Fetch API

Initial Title
JS Fetch: Get JSON data from server

Initial Tags


Initial Language
JavaScript