Answers for "make a fetch call and get data in a variable js"

0

getdata from fetch api into variable

function getData(url, cb) {
  fetch(url)
    .then(response => response.json())
    .then(result => cb(result));
}

getData(url, (data) => console.log({ data }))
Posted by: Guest on September-23-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language