UNPKG

@gdwc/drupal-state

Version:

A simple data store to manage application state sourced from Drupal's JSON:API.

14 lines (8 loc) 587 B
'use strict'; var f = require('isomorphic-fetch'); function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; } var f__default = /*#__PURE__*/_interopDefault(f); var m=(r,o={},t)=>f__default.default(r,o),s=m;var c=(r,o={},t=n=>{throw n},p,a=s)=>a(r,o,p).then(e=>{if(!e.ok)throw new Error(`Failed to fetch JSON:API endpoint. Tried fetching: ${r} Server responded with status code: ${e.status}`);return e.json()}).then(e=>e).catch(e=>{t(e);}),i=c;var d=async(r,o,t={},p=!1,a=s,n=e=>{throw e})=>await i(r+"?path="+o+"&_format=json",t,n,p,a),A=d; module.exports = A;