Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

188
Views
node.js axios request with cookies

so i have browser(netscape?) cookie like that nscookie or JSON cookie like jsoncookie

How should i pass this into request?

code source:

const
    fs = require('fs'),
    https = require('https'),
    axios = require('axios');

function reqTest()
{

    axios.default.request({
        'url': 'google.com',
        'method': 'post',
        'headers':
            {
                'Cookie': 'cookie1=?; cookie2=?;'
            }
    }
    ).then(res => {
        console.log(res);
    })
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Having the withCredentials key enabled (set to 'true') should solve your issue.

Please try this:

const
    fs = require('fs'),
    https = require('https'),
    axios = require('axios');

function reqTest()
{

    axios.default.request({
        'url': 'google.com',
        'method': 'post',
        'headers':
            {
                'Cookie': 'cookie1=?; cookie2=?;'
            },
        'withCredentials: true" // ADD THIS LINE
    }
    ).then(res => {
        console.log(res);
    })
}

You can also enable this property for all requests in this instance of axios, changing axios' defaults:

axios.defaults.withCredentials = true;

axios.post(url, body).then(...).catch(...); // withCredentials is automatically enabled

Please report results.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!