https://github.com/system233/node-axios-cookies
https://github.com/system233/node-axios-cookies
Last synced: 21 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/system233/node-axios-cookies
- Owner: System233
- License: mit
- Created: 2024-04-13T03:59:43.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-04-13T10:01:35.000Z (over 1 year ago)
- Last Synced: 2024-10-30T00:30:28.266Z (about 1 year ago)
- Language: JavaScript
- Size: 23.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Axios-Cookie
A Cookie support library for Axios, automatically manages cookies on request, just like `request.Session`.
## Documentation
See the [Documentation](/docs/modules.md) for details.
## Example
```ts
import { setupCookieJar } from 'axios-cookie'
import axios from 'axios'
// Create a Axios instance
const instance = axios.create()
// Setup CookieJar, All cookies will be stored here.
const jar = setupCookieJar(instance,)
// Access value in CookieJar through Key.
jar.setValue(,'key','value')
jar.getValue(,'key')
// Remove a key
jar.setValue(,null)
// Send a Request that will include the `Cookie` header configured in CookieJar.
instance.get();
// Get the Cookie Header value for site .
jar.getCookie()
// Put Set-Cookie Header into the CookieJar.
jar.setCookie(,)
// Import from/Export to JSON Object.
jar.toJSON()
jar.fromJSON(obj)
// Get the internal CookieJar Storage, `cookiejar` or `tough-cookie`.
jar.toRaw()
```
## Adapters
There are currently two CookieJar stores supported by default:
1. [SimpleCookieJarAdapter](/docs/classes/adapters_cookiejar.SimpleCookieJarAdapter.md), powered by [cookiejar](https://github.com/bmeck/node-cookiejar). [default,built-in].
Very fast and tiny, x5~x6 faster than tough-cookie.
The original version has too few functions and has been modified to adapt to the new functions.
Built-in features, no additional installation required.
2. [ToughCookieJarAdapter](/docs/classes/adapters_tough.ToughCookieJarAdapter.md), powered by [tough-cookie](https://github.com/salesforce/tough-cookie).
Slow and large, but powerful!
Need to install `tough-cookie` manually.
## Test
```shell
npm run test
# or
yarn run test
# or
node --test
```
## LICENSE
[MIT](/LICENSE) License