@gdwc/drupal-state
Version:
A simple data store to manage application state sourced from Drupal's JSON:API.
13 lines (7 loc) • 604 B
JavaScript
;
var p = require('isomorphic-fetch');
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
var p__default = /*#__PURE__*/_interopDefault(p);
var d=(o,e={},n)=>p__default.default(o,e),a=d;var i=(o,e,n=a,s=r=>{throw r})=>{let r=Object.keys(e).map(t=>`${t}=${e[t]}`).join("&");return n(o,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:r}).then(t=>{if(!t.ok)throw new Error(`Unable to fetch token.
The server responded with status code ${t.status}`);return t.ok&&t.json()}).then(t=>t).catch(t=>{s(t);})},u=i;
module.exports = u;