如何从expressjs服务器发送xhttp请求



我正试图从后端向linkedin服务发送一个post请求。

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();
}

我得到以下错误:

TypeError:无法读取未定义的属性"堆栈">

到目前为止,此方法运行良好。

我错误地使用了"xhttp.handleError((",我删除了它,现在它工作正常。

最新更新