我想在本地调试代码,本地用node 启动了一个服务,在微信开发者工具里面访问local host:3000/test.html ,可以访问到。我下面写了一段js,是获取token的,但是总是报跨域的错误?该如何解决
XMLHttpRequest cannot load https://api.weixin.qq.com/cgi... No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://ec72ea06.ngrok.io' is therefore not allowed access.
这个id和secrect填的都是我测试号。我想本地拿到token,该怎么做?
$(function(){
// alert(111)
$.ajax({
url:"https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=xxxx&secret=xxxxx",
success:function(res){
console.log(res)
},
error:function(err){
console.log(222)
}
})
})