axiosCookieJarSupport is not a function

1.2k views Asked by At

I am attempting to use the axios-cookiejar-support library to no avail.
Here is my code:

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

axiosCookieJarSupport(axios)
const cookieJar = new tough.CookieJar();

axios.post('https://auth.riotgames.com/api/v1/authorization', {
    client_id: "play-valorant-web-prod",
    nonce: 1,
    redirect_uri: "https://playvalorant.com/opt_in",
    response_type: "token id_token"
}, {jar: cookieJar, withCredentials: true})
.then(response => {
 
    axios.put('https://auth.riotgames.com/api/v1/authorization', {
        "type": "auth",
        "username": "tbd",
        "password": "tbd",
        "remember": true,
        "language": "en_US"
    }, {jar: cookieJar, withCredentials: true})
    .then(response => console.log(response))

})

I get the error

TypeError: axiosCookieJarSupport.default is not a function
    at Object.<anonymous> (C:\Workspace\Valorant\valorant-shop-tracker\test.js:5:30)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47

This is just a node.js script, not on browser not with another library.
I have axios, axios-cookiejar-support and tought-cookie installed.

1

There are 1 answers

0
Nash Anderson On

I really don't know what I was doing... but I followed the example code again and chained the succeeding requests into the previous requests .then(). I originally didn't do this which caused a seperate issue, leading me to do this weird... I don't even know.