๐ Opinionated wrapper to the browser's default fetch method.
npm i -S joemccann/enhanced-fetch
In your web app:
const Fetch = require('enhanced-fetch')
const fetch = new Fetch({root: 'https://www.your-domain.com'})
~(async () => {
const { err, data, res } = await fetch.request('path/to/api', {
method: 'POST',
body: {
name: 'Joe',
email: '[email protected]'
},
headers: {
'x-custom-api-header': 'XXX'
}
})
if(err) console.error(err)
else console.log(data)
})();
MIT