How to use the axios-cookiejar-support.default function in axios-cookiejar-support

To help you get started, we’ve selected a few axios-cookiejar-support examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github 3846masa / axios-cookiejar-support / example / set-default.js View on Github external
'use strict';

const axios = require('axios').default;
const tough = require('tough-cookie');
const axiosCookieJarSupport = require('axios-cookiejar-support').default;

axiosCookieJarSupport(axios);

const cookieJar = new tough.CookieJar();
axios.defaults.jar = cookieJar;
axios.defaults.withCredentials = true;

axios
  .get('https://google.com')
  .then((response) => {
    const config = response.config;
    // axios.defaults.jar === config.jar
    console.log(config.jar.toJSON());
  })
  .catch((err) => {
    console.error(err.stack || err);
  });
github 3846masa / axios-cookiejar-support / example / send-cookies.js View on Github external
'use strict';

const axios = require('axios').default;
const tough = require('tough-cookie');
const axiosCookieJarSupport = require('axios-cookiejar-support').default;

axiosCookieJarSupport(axios);

const cookieJar = new tough.CookieJar();
cookieJar.setCookieSync('key=value; domain=mockbin.org', 'https://mockbin.org');

axios
  .get('https://mockbin.org/request', {
    jar: cookieJar,
    withCredentials: true, // IMPORTANT!
  })
  .then((response) => {
    const data = response.data;
    console.log(data.headers.cookie);
  })
  .catch((err) => {
    console.error(err.stack || err);
  });
github mirusresearch / ipCloudy / src / providers / azure.js View on Github external
/* global module, require */

const _ = require('lodash');
const xml = require('xml2js');
const axios = require('axios');
const Promise = require('bluebird');

const axiosCookieJarSupport = require('axios-cookiejar-support').default;

axiosCookieJarSupport(axios);
const parse = Promise.promisify(xml.parseString);

const uri = 'https://www.microsoft.com/en-us/download/confirmation.aspx?id=41653';
const fileRegex = /href="(.*?PublicIPs.*?xml)"/;

module.exports = async function() {
    let response = await axios.get(uri, { jar: true, withCredentials: true });
    let page = response.data;

    let uriMatches = fileRegex.exec(page);
    if (uriMatches.length < 2) {
        throw new Error('Azure: No file download urls found at ' + uri);
    }
    let rangeXMLUri = uriMatches[1];

    let xmlResponse = await axios.get(rangeXMLUri, { jar: true, withCredentials: true });
github Accretion-dev / Accretion / brainhole / test-src / api.js View on Github external
import axios from 'axios'
import Rews from "../utils/reconnect-ws"
import configs from "../configs/config.js"
import WebSocket from 'ws'

const host = configs.host
const port = configs.port

const axiosCookieJarSupport = require('axios-cookiejar-support').default
const tough = require('tough-cookie')
axiosCookieJarSupport(axios)
const cookieJar = new tough.CookieJar()

const www = axios.create({
  baseURL: `http://${host}:${port}`,
  timeout: 5000,
  withCredentials: true,
  jar: cookieJar,
})

const defaultUser = {
  username: "accretion",
  password: "cc",
}

var d = global.d = {}
d.www = www
github 3846masa / axios-cookiejar-support / example / simple.js View on Github external
'use strict';

const axios = require('axios').default;
const tough = require('tough-cookie');
const axiosCookieJarSupport = require('axios-cookiejar-support').default;

axiosCookieJarSupport(axios);

const cookieJar = new tough.CookieJar();

axios
  .get('https://google.com', {
    jar: cookieJar,
    withCredentials: true,
  })
  .then((response) => {
    const config = response.config;
    console.log(config.jar.toJSON());
  })
  .catch((err) => {
    console.error(err.stack || err);
  });
github Luidog / fms-api-client / src / services / request.service.js View on Github external
'use strict';

const axios = require('axios');
const axiosCookieJarSupport = require('axios-cookiejar-support').default;

const instance = axios.create();

axiosCookieJarSupport(instance);

/**
 * @class Request Service
 */

/**
 * @method interceptError
 * @private
 * @description This method evaluates the error response. This method will substitute
 * a non json error or a bad gateway status with a json code and message error. This
 * method will add an expired property to the error response if it recieves a invalid
 * token response.
 * @param  {Object} error The error recieved from the requested resource.
 * @return {Promise}      A promise rejection containing a code and a message
 */
github Luidog / fms-api-client / src / services / request.service.js View on Github external
'use strict';

const axios = require('axios');
const axiosCookieJarSupport = require('axios-cookiejar-support').default;

const instance = axios.create();

axiosCookieJarSupport(instance);

/**
 * @class Request Service
 */

/**
 * @method interceptError
 * @private
 * @description This method evaluates the error response. This method will substitute
 * a non json error or a bad gateway status with a json code and message error. This
 * method will add an expired property to the error response if it recieves a invalid
 * token response.
 * @param  {Object} error The error recieved from the requested resource.
 * @return {Promise}      A promise rejection containing a code and a message
 */
const interceptError = error => {
github autonomoussoftware / metronome-wallet-desktop / public / main / plugins / bloq-eth-explorer / index.js View on Github external
'use strict'

const { CookieJar } = require('tough-cookie')
const axios = require('axios')
const axiosCookieJarSupport = require('axios-cookiejar-support').default
const io = require('socket.io-client')
const logger = require('electron-log')

const createBasePlugin = require('../../base-plugin')

const { getIndexerApiUrl } = require('./settings')
const api = require('./api')

axiosCookieJarSupport(axios)

const baseURL = getIndexerApiUrl()

const jar = new CookieJar()

const setTimeoutAsync = timeout => new Promise(function (resolve) {
  setTimeout(resolve, timeout)
})

const getSocket = () =>
  axios.get(baseURL, { jar, withCredentials: true })
    .then(function () {
      return io(`${baseURL}/v1`, {
        autoConnect: false,
        extraHeaders: {
          Cookie: jar.getCookiesSync(baseURL).join(';')
github Luidog / fms-api-client / src / models / agent.model.js View on Github external
const https = require('https');
const http = require('http');
const uuidv4 = require('uuid/v4');
const { EmbeddedDocument } = require('marpat');
const _ = require('lodash');
const { deepMapKeys } = require('../utilities');
const { Connection } = require('./connection.model');

const axios = require('axios');
const axiosCookieJarSupport = require('axios-cookiejar-support').default;
const { omit } = require('../utilities');

const instance = axios.create();

axiosCookieJarSupport(instance);

/**
 * @class Agent
 * @classdesc The class used to model the axios http instance and agent
 */
class Agent extends EmbeddedDocument {
  /** @constructs */
  constructor() {
    super();
    this.schema({
      /**
       * The global id for an http or https.agent
       * @member Agent#global
       * @type String
       */
      global: {

axios-cookiejar-support

Add tough-cookie support to axios.

MIT
Latest version published 2 months ago

Package Health Score

80 / 100
Full package analysis

Popular axios-cookiejar-support functions