小程序
小游戏
企业微信
微信支付
扫描小程序码分享
报错:“https://api.weixin.qq.com 不在以下 request 合法域名列表中,”
给出的解释是:“微信公众平台小程序后台的服务器地址设置也将禁止将“api.weixin.qq.com”域名的配置,所有对于“api.weixin.qq.com”域名下的接口请求请全部通过后台服务器发起,请勿直接通过小程序的前端代码发起。”
是否意味着消息模板还是需要后台服务器的支持?既然小程序推出了云开发,目的是减少后台服务器的设置和维护,那这块建议也一并考虑
1 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
可以是云函数 不过 acc token 有点麻烦 。因为没有定时函数
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
谢谢,试了下云函数,没有报错,但始终返回null,求解
{errMsg: "cloud.callFunction:ok", result: null, requestID: "3860b1e7-cc89-11e8-a0ac-525400e8849e"}
控制台信息:
返回结果:
null
日志:
START RequestId: 3860b1e7-cc89-11e8-a0ac-525400e8849e
Event RequestId: 3860b1e7-cc89-11e8-a0ac-525400e8849e Event:{"formId":"the formId is a mock one","userInfo":{"appId":"*****","openId":"*****"}}
END RequestId: 3860b1e7-cc89-11e8-a0ac-525400e8849e
Report RequestId: 3860b1e7-cc89-11e8-a0ac-525400e8849e Duration:184.506ms Memory:256MB MaxMemoryUsed:2.36719MB
//npm install request-promise
const rp = require('request-promise');
// 云函数入口函数
exports.main = async(event, context) => {
var res = await rp(
{
method: 'get',
uri: 'https://xxxx.com',
qs: { },//参数
headers: {},//请求头
json: true //是否json数据
}
).then(( body) => {
return body
}).catch(err => {
return err;
})
return res;
谢谢指导,果然ok,刚开始没有理解wx.request与request-promise的区别,走了些弯路
ps:我用的是post方式,把qs改成了body
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
可以是云函数 不过 acc token 有点麻烦 。因为没有定时函数
谢谢,试了下云函数,没有报错,但始终返回null,求解
{errMsg: "cloud.callFunction:ok", result: null, requestID: "3860b1e7-cc89-11e8-a0ac-525400e8849e"}
控制台信息:
返回结果:
null
日志:
START RequestId: 3860b1e7-cc89-11e8-a0ac-525400e8849e
Event RequestId: 3860b1e7-cc89-11e8-a0ac-525400e8849e Event:{"formId":"the formId is a mock one","userInfo":{"appId":"*****","openId":"*****"}}
END RequestId: 3860b1e7-cc89-11e8-a0ac-525400e8849e
Report RequestId: 3860b1e7-cc89-11e8-a0ac-525400e8849e Duration:184.506ms Memory:256MB MaxMemoryUsed:2.36719MB
//npm install request-promise
const rp = require('request-promise');
// 云函数入口函数
exports.main = async(event, context) => {
var res = await rp(
{
method: 'get',
uri: 'https://xxxx.com',
qs: { },//参数
headers: {},//请求头
json: true //是否json数据
}
).then(( body) => {
return body
}).catch(err => {
return err;
})
return res;
}
谢谢指导,果然ok,刚开始没有理解wx.request与request-promise的区别,走了些弯路
ps:我用的是post方式,把qs改成了body