Releases: fiverr/gofor
Releases · fiverr/gofor
gofor version 2.0 - interface updates (breaking change)
Migration from 1.X to 2 (also from @fiverr/gofor
to plain gofor
)
"Out of the box" Instance remains the same
Before
const {gofor} = require('@fiverr/gofor');
After
const {gofor} = require('gofor');
replace use of goforFactory (deprecated); two options are available
Before
const goforFactory = require('@fiverr/gofor');
const gofor = goforFactory(() => ({...}));
After
const Gofor = require('gofor');
const gofor = new Gofor(() => ({...})).fetch;
Or
const {gofor} = require('gofor');
gofor.config(() => ({...}))
Add a simpler interface - instance getter
Hopefully, a simpler interface
Get a gofor instance directly. Gofor instances are now configurable also after creation
const {gofor} = require('@fiverr/gofor');
gofor('/thing');
gofor.config({credentials: 'same-origin'});
gofor('https://www.other-website.com/other-thing');
Support Headers object
Supports headers as object literals or Headers instances in both
Default header keys will be run over if matched by passed in header keys. Other keys will be merged. This is made by design.
Example
const gofor = goforFactory({
credentials: 'same-origin',
headers: new Headers({
'Content-Type': 'application/json; charset=utf-8',
'X-Custom-Header': 'Custom-Value'
})
});
gofor('/page', {
headers: new Headers({
'Content-Type': 'text/plain',
})
});
Final headers will be:
'Content-Type': 'text/plain',
'X-Custom-Header': 'Custom-Value'