Answers for "javascript fetch json from url"

4

how get a json object from an api in javascript

let url = 'https://example.com';

fetch(url)
.then(res => res.json())
.then((out) => {
  console.log('Checkout this JSON! ', out);
})
.catch(err => { throw err });
Posted by: Guest on March-17-2020
19

fetch api javascript

fetch('http://example.com/movies.json')
  .then((response) => {
    return response.json();
  })
  .then((myJson) => {
    console.log(myJson);
  });
Posted by: Guest on February-10-2020
44

convert fetch data to json

fetch("localhost:3000/api/home") // first step
  .then(response => response.json()) // second step
  .then(data => {
    console.log(data)
  })
  .catch(error => console.error(error))
Posted by: Guest on October-08-2021
1

get jsonp with fetch

fetchJsonp('/users.jsonp')
  .then(function(response) {
    return response.json()
  }).then(function(json) {
    console.log('parsed json', json)
  }).catch(function(ex) {
    console.log('parsing failed', ex)
  })
Posted by: Guest on September-22-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language