Skip to content

Releases: fiverr/gofor

gofor version 2.0 - interface updates (breaking change)

11 Nov 09:59
5d2d0bb
Compare
Choose a tag to compare

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

30 Jul 11:23
a8646f4
Compare
Choose a tag to compare

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

08 Nov 13:30
c80bb36
Compare
Choose a tag to compare

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'