Skip to content

Add tough-cookie support to axios with configurable http(s)-agents.

License

Notifications You must be signed in to change notification settings

maugenst/axios-with-cookies

Repository files navigation

axios-with-cookies

axios-with-cookies Background-Photo by Lisa Fotios

npm license

axios-with-cookies

This project is a fork of axios-cookiejar-support which lacks the possibility to add configurable http(s)-agents. It is based on the initial work of Masahiro Miyashiro (@3846masa).

Table of Contents

Install

npm install axios tough-cookie axios-with-cookies

Usage

import * as axios from 'axios';
import {AxiosInstance, AxiosStatic} from 'axios';
import {CookieJar, MemoryCookieStore} from 'tough-cookie';
import {wrapper} from 'axios-cookiejar-support';

const axiosInstance: AxiosInstance = ((axios as unknown) as AxiosStatic).create({
  httpsAgent: new HttpsCookieAgent({
    cookies: {
      jar: new CookieJar(new MemoryCookieStore(), {looseMode: true})      
    },
    rejectUnauthorized: false,
    keepAlive: true,
    timeout: 100000
  })
});
this.client = wrapper(axiosInstance);

await this.client.get('https://example.com');

See examples for more details.

Contributing

PRs welcome.

License

MIT (c) maugenst

About

Add tough-cookie support to axios with configurable http(s)-agents.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages