cookie-api-handler
v2.25.15
Published
Handler for cookie APIs
Downloads
838
Readme
Cookie API Handler
Extension of rest-api-handler library. It parse cookies from response headers and use them to send requests.
Library is compiled for node 9.6 and include Fetch polyfill.
How to use it
Install the library:
npm install cookie-api-handler
Send requests:
const CookieApi = require('cookie-api-handler');
(async () => {
const api = new CookieApi('');
await api.get('https://endomondo.com');
console.log(api.getCookies());
})();
For more information about sending requests, check base library.
How to work with cookies
Cookies are inserted to object based on response headers. Class have methods to add custom cookies and read the current ones:
// will return object of decoded strings
api.getCookies();
// you can add custom cookies, string only. Cookies will be encoded.
api.addCookies({
cookieName: 'cookieValue',
});