I am trying to use Axios, because it's the only module with async/await feature with NodeJS.
I already have a POST request in Python script, which work very well, and I am trying to adapt on NodeJS server.
But I block on my first post request. If i use with Request module directly, it's work very well, see my code :
console.log("create session");
let data = {'uname': 'login', 'pass': 'password', 'module':'NSUser', 'op':'login','url':'%2Findex.php'}
let url = 'https://localhost:9000/user.php'
let headers = {'Accept': "application/html"}
//s = request.session
body = await request.post({url:url, headers:headers, form:data}, function(error, response, body){
console.log("LOGIN");
console.log(response);
});
With Axios (or Axios instance but it's for later...) because i will need to keep my session (like in Python it work like a charm).
const config = {
method: 'post',
url: 'https://localhost:9000/user.php',
headers: {'content-type': 'application/x-www-form-urlencoded'},
data: {uname:'login',
pass:'password',
module:'NSUser',
op:'login',
url:'/index.php'}
}
axios(config)
And the body in response, it's not connecting page than the code with Request.
What i am wrong ? I try to replace data by param, but it's same....
I have CURL command from Firefox if i need.
For information, in python :
s = requests.session()
res = s.post(url, headers=headers, data=data)
and my s variable have the session, and can request everything as connected.