简体   繁体   中英

How to send an xhttp request from an expressjs server?

I'm trying to send a post request to linkedin services from my backend.

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

And I get below error :

TypeError: Cannot read property 'stack' of undefined

This method was working fine until now.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM