cookie-api-handler

Handler for cookie APIs

Usage no npm install needed!

<script type="module">
  import cookieApiHandler from 'https://cdn.skypack.dev/cookie-api-handler';
</script>

README

Cookie API Handler

npm version renovate-app Known Vulnerabilities codecov travis

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',
});