大佬帮忙看看这段代码有什么问题吗?为什么总是报appid找不到?
var token = await request({
url: "https://api.weixin.qq.com/cgi-bin/stable_token",
method: "POST",
json: true,
form: {
grant_type: "client_credential",
appid: "wxa4f5a91xxxx6f5",
secret: "d83eb0344cxxxxcbfa9aa917e03e"
},
headers: {
"content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
},
})
{
"errcode": 41002,
"errmsg": "appid missing rid: 65107638-2348b85b-0a154fd2"
}
发送JSON 数据。不是数组参数。
你在小程序端调用小程序的api?
Content-Type是application/json,不是 application/x-www-form-urlencoded
curl命令可以正常访问,应该是代码哪里有问题,新手上路,大佬们请指教!
const got = require('got')
const resultValue_options = {
method: 'POST',
url: "https://api.weixin.qq.com/cgi-bin/stable_token",
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
grant_type: "client_credential",
appid: "wxa4f5a91e38beb6f5",
secret: "d83eb0344c7ce53816cbfa9aa917e03e"
}),
responseType: 'json'
};
console.log("buffer======1111");
var {body} = await got(resultValue_options)
console.log("buffer", body);