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

Javascript 如何从expressjs服务器发送xhttp请求?,javascript,node.js,express,post,Javascript,Node.js,Express,Post,我正在尝试从后端向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

我正在尝试从后端向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:无法读取未定义的属性“堆栈”


这个方法到目前为止还可以正常工作。

我使用的“xhtp.handleError()”错误,我删除了它,现在它可以正常工作。

我使用的“xhtp.handleError()”错误,我删除了它,现在它可以正常工作。

你提供的代码根本没有使用
堆栈。@Quentin我不知道什么是“堆栈”。我自己不使用它。可能调试器会告诉您它来自哪个文件和行。为什么不使用请求承诺npm模块?@DeepKakkar-请求承诺所依赖的
请求
模块已弃用。不要使用它。你提供的代码根本不使用堆栈。@Quentin我不知道什么是堆栈。我自己不使用它。可能调试器会告诉您它来自哪个文件和行。为什么不使用请求承诺npm模块?@DeepKakkar-请求承诺所依赖的
请求
模块已弃用。不要用它。