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