javascript - 如何从 expressjs 服务器发送 xhttp 请求?
问题描述
我正在尝试从我的后端向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();
}
我得到以下错误:
TypeError:无法读取未定义的属性“堆栈”
到目前为止,这种方法运行良好。
解决方案
我错误地使用了“xhttp.handleError()”,我删除了它,现在它可以正常工作了。
推荐阅读
- angular - 如何在表单数组内的自动完成中添加服务中的数据?
- php - 如何验证该值是否已存在。PHP
- php - 使用 ZendServer 连接到外部 DB2
- python - 如何向networkx散景图添加分类图例
- python -
- python - Python - 单个 for 循环,计算以下 to_analyze 中每行的最大、最小和平均字数
- html - 文字太小而无法阅读(移动设计)
- xamarin.forms - Xamarin 表单:点击和双击
- mysql - sqoop如何在增量导入中导入固定数量的行?
- php - Bootstrap 无法在 Laravel Blade 中正确显示