site/node_modules/d3-fetch/src/json.js

10 lines
300 B
JavaScript
Raw Normal View History

2024-10-14 06:09:33 +00:00
function responseJson(response) {
if (!response.ok) throw new Error(response.status + " " + response.statusText);
if (response.status === 204 || response.status === 205) return;
return response.json();
}
export default function(input, init) {
return fetch(input, init).then(responseJson);
}