关于微信开发者工具使用问题?里面的js-sdk功能如何使用

  1. 我想在本地调试代码,本地用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,该怎么做?

clipboard.png

$(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)
        }
    })
})
阅读 3.6k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题