Spaces:
Running
Running
File size: 1,878 Bytes
95f4e64 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# axios-cookiejar-support

[](https://github.com/sponsors/3846masa)
[](https://www.npmjs.com/package/axios-cookiejar-support)
[](LICENSE)
[](https://github.com/RichardLitt/standard-readme)
Add `tough-cookie` support to axios.
## Table of Contents
- [Install](#install)
- [Usage](#usage)
- [Extended Request Config](#extended-request-config)
- [Contributing](#contributing)
- [License](#license)
## Install
```
npm install axios tough-cookie axios-cookiejar-support
```
## Usage
```js
import axios from 'axios';
import { wrapper } from 'axios-cookiejar-support';
import { CookieJar } from 'tough-cookie';
const jar = new CookieJar();
const client = wrapper(axios.create({ jar }));
await client.get('https://example.com');
```
See [examples](./examples) for more details.
### Extended Request Config
```ts
import type { CookieJar } from 'tough-cookie';
declare module 'axios' {
interface AxiosRequestConfig {
jar?: CookieJar;
}
}
```
See also https://github.com/axios/axios#request-config .
## FAQ
- Q. Why can't I assign the httpAgent / httpsAgent?
- A. axios-cookiejar-support uses httpAgent / httpsAgent to read and write cookies. If other Agents are assigned, cookies cannot be read/written.
- Q. I want to use it with another Agent (e.g., http-proxy-agent).
- A. Consider using http-cookie-agent. axios-cookiejar-support also uses http-cookie-agent. Read http-cookie-agent's README for more details.
## Contributing
PRs accepted.
## License
[MIT (c) 3846masa](./LICENSE)
|