簡體   English   中英

Nodejs發布請求

[英]Nodejs post request

我正在嘗試使用以下請求登錄網站:

var request = require('request');

var options = {
method: 'POST',
url: 'https://server/EnterpriseController',
params: {a: 1},
form: "actionType=authenticateUser&reqObj=[null,username,password,null,1]",
headers: {
    'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'

},
withCredentials: true,
rejectUnauthorized: false
};

request(options,
function (error, response, body, data) {

    if (request.method === 'POST') {
        var body = '';
        request.on('data', function (data) {
            body += data;
        });
        request.on('end', function () {
            var post = qs.parse(body);
        });
    }
    console.log(body);
}
);

我總是遇到錯誤。 我認為表格是錯誤的,但我在angularjs網站上的登錄名相同,沒有任何錯誤。 我不明白為什么登錄可以在angularjs網站上運行,而不能在nodejs網站上運行。

 )]}',
 {"login_err": true, "resp": [null,null,null,1]
 }

我錯過了cookie:/並且Formdata應該是一個對象。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM