Skip to content

Instantly share code, notes, and snippets.

@kieranbarker

kieranbarker/getJSON.js

Last active Dec 6, 2020
Embed
What would you like to do?
Get the JSON data from a Fetch request
/**
* Get the JSON data from a Fetch request
* @param {Response} response The Response object
* @returns {Promise} The JSON data or the rejected response
* @license MIT
*/
function getJSON (response) {
return response.ok ? response.json() : Promise.reject(response);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment