1.1.0 • Published 1 year ago

superagent-fetch v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

superagent-fetch

Use it to display your superagent request likes fetch method. Useful when want to compare with a request copied from browser.

const agent = require('superagent');
const superagentToFetch = require('superagent-fetch');

const fetched = agent
    .get('/status')
    .use(superagentToFetch)
    .toFetch();

console.log(fetched);

// Will display this
/*

fetch("/status", {
    "method": "GET"
});
*/

A more commplex example:

const agent = require('superagent');
const superagentToFetch = require('superagent-fetch');

const fetched = agent
    .post('/status')
    .set('Content-Type', 'application/json; charset=utf-8')
    .send({foo: 'bar', exec: true})
    .use(superagentToFetch)
    .toFetch();

console.log(fetched);

// Will display this
/*

fetch("/status", {
    "headers": {
        "content-type": "application/json; charset=utf-8"
    },
    "body": "{\"foo\":\"bar\",\"exec\":true}",
    "method": "POST"
});
*/
1.1.0

1 year ago

1.0.1

2 years ago

1.0.0

2 years ago