簡體   English   中英

如何從 expressjs 服務器發送 xhttp 請求?

[英]How to send an xhttp request from an expressjs server?

我正在嘗試從我的后端向linkedin 服務發送發布請求。

exports.GetAccessToken = function (req, res) {
var xhttp = new XMLHttpRequest();
var decoded = jwt.verify(req.query.jwt_token, MariaDB_config.PUB_key);
xhttp.onreadystatechange = function () { // handle request response
  if (this.readyState === 4 && this.status === 200) {
    console.log("answer : " + this.responseText);
  }
};
xhttp.handleError()
// Send a post request
xhttp.open("POST", "https://www.linkedin.com/oauth/v2/accessToken?code=" + decoded.code + "privatestuff", true);
xhttp.send();
}

我得到以下錯誤:

類型錯誤:無法讀取未定義的屬性“堆棧”

到目前為止,這種方法運行良好。

我錯誤地使用了“xhttp.handleError()”,我刪除了它,現在它工作正常。

暫無
暫無

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

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