企业微信跨域请求解决方式
node后台通过request转发请求,实现跨域获取数据
前端js:
$.ajax({
type:"GET",
url:"/getAccessToken",
dataType:"json",
success:function(data){
console.log(data);
},
error:function(errMsg){
console.log("请求失败");
}
});
后端:
router.get('/getAccessToken',function(req,res,next){
request("https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid="+Corpid+"&corpsecret="+Secret, function (error, response, body) {
if (!error && response.statusCode == 200) {
res.send(body);
}else{
res.send({});
}
});
});
参考资料:
http://lib.csdn.net/article/wechat/167
https://blog.csdn.net/dreamer2020/article/details/52074516