@fyrepenguin/gatsby-source-dega
Version:
<h1 align="center"> @factly/gatsby-source-dega </h1> Source from [DegaCMS](https://dega.factly.in) API in Gatsby.
18 lines (14 loc) • 478 B
JavaScript
const nodeFetch = require(`isomorphic-fetch`);
/**
* Wrapper/Polyfill for fetch function for Apollo Client
* @param {string} uri - uri of the api
* @param {Object} options - options for nodeFetch
* @returns {Object}
*/
exports.fetchWrapper = async (uri, options) => {
const response = await nodeFetch(uri, options);
if (response.status >= 400) {
throw new Error(`Source DEGA API: HTTP error ${response.status} ${response.statusText}`);
}
return response;
};