Skip to content

Instantly share code, notes, and snippets.

@blubbll
Last active August 13, 2019 11:24
Show Gist options
  • Save blubbll/0e59fd93a44214d7d8acda459cfbf8f8 to your computer and use it in GitHub Desktop.
Save blubbll/0e59fd93a44214d7d8acda459cfbf8f8 to your computer and use it in GitHub Desktop.
fetchjson
getJson: function(url, options = {}) {
try {
const req = fetch(url)
.then(async (response) => {
const json = await response.text()
return JSON.parse(json);
})
.catch((err) => {
console.warn(err)
});
// Returns a promise
return req;
} catch (e) {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment