企业微信跨域请求解决方式


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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM