JSPM

  • Created
  • Published
  • Downloads 325237
  • Score
    100M100P100Q183810F
  • License MIT

Add tough-cookie support to axios.

Package Exports

  • axios-cookiejar-support
  • axios-cookiejar-support/dist/index.d.ts
  • axios-cookiejar-support/dist/index.js
  • axios-cookiejar-support/noop.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (axios-cookiejar-support) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

axios-cookiejar-support

axios-cookiejar-support

github sponsors npm license standard-readme compliant

Add tough-cookie support to axios.

Table of Contents

Install

npm install axios tough-cookie axios-cookiejar-support

Usage

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 for more details.

Extended Request Config

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