axios-with-cookies
v1.0.2
Published
Fork of axios-cookiejar-support with configurable http(s)-agent
Downloads
51
Maintainers
Readme
axios-with-cookies
Background-Photo by Lisa Fotios
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.