Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fabulator/cookie-api-handler
Cookies for rest-api-handler
https://github.com/fabulator/cookie-api-handler
api cookie
Last synced: 13 days ago
JSON representation
Cookies for rest-api-handler
- Host: GitHub
- URL: https://github.com/fabulator/cookie-api-handler
- Owner: fabulator
- License: apache-2.0
- Created: 2018-05-07T10:50:48.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-03-31T23:22:17.000Z (10 months ago)
- Last Synced: 2024-04-01T00:24:04.602Z (10 months ago)
- Topics: api, cookie
- Language: TypeScript
- Size: 4.88 MB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Cookie API Handler
[![npm version](https://badge.fury.io/js/cookie-api-handler.svg)](https://badge.fury.io/js/cookie-api-handler)
[![renovate-app](https://img.shields.io/badge/renovate-app-blue.svg)](https://renovateapp.com/)
[![Known Vulnerabilities](https://snyk.io/test/github/fabulator/cookie-api-handler/badge.svg)](https://snyk.io/test/github/fabulator/cookie-api-handler)
[![codecov](https://codecov.io/gh/fabulator/cookie-api-handler/branch/master/graph/badge.svg)](https://codecov.io/gh/fabulator/cookie-api-handler)
[![travis](https://travis-ci.org/fabulator/cookie-api-handler.svg?branch=master)](https://travis-ci.org/fabulator/cookie-api-handler)Extension of [rest-api-handler](https://github.com/fabulator/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:
```nodedaemon
npm install cookie-api-handler
```Send requests:
```javascript
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](https://github.com/fabulator/rest-api-handler).
## 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:
```javascript
// will return object of decoded strings
api.getCookies();// you can add custom cookies, string only. Cookies will be encoded.
api.addCookies({
cookieName: 'cookieValue',
});
```