UNPKG

@gdwc/drupal-state

Version:

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

7 lines (4 loc) 442 B
import p from 'isomorphic-fetch'; var d=(o,e={},n)=>p(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; export { u as default };