Request ID
80729bc2-3e1a-4143-9229-d6a770f5487f
调用状态
失败, ret code 1
返回结果
{“errorCode”:1,“errorMessage”:“user code exception caught”,“stackTrace”:“Error: errCode: -501007 invalid parameters | errMsg: urlscheme.generate:fail Invalid request param\n at callGeneralOpenAPI (/var/user/node_modules/wx-server-sdk/index.js:425:19)\n at process._tickCallback (internal/process/next_tick.js:68:7)”,“statusCode”:430}
调用日志
START RequestId:80729bc2-3e1a-4143-9229-d6a770f5487f
2021-01-29T12:32:29.076Z 80729bc2-3e1a-4143-9229-d6a770f5487f { action: ‘getUrlScheme’ }
ERROR RequestId:80729bc2-3e1a-4143-9229-d6a770f5487f Result:{“errorCode”:1,“errorMessage”:“user code exception caught”,“stackTrace”:“Error: errCode: -501007 invalid parameters | errMsg: urlscheme.generate:fail Invalid request param\n at callGeneralOpenAPI (/var/user/node_modules/wx-server-sdk/index.js:425:19)\n at process._tickCallback (internal/process/next_tick.js:68:7)”,“statusCode”:430}
END RequestId:80729bc2-3e1a-4143-9229-d6a770f5487f
云函数源码:
// 云函数入口文件
const cloud = require('wx-server-sdk')
cloud.init({
env: cloud.DYNAMIC_CURRENT_ENV
})
// 云函数入口函数
exports.main = async (event, context) => {
const wxContext = cloud.getWXContext()
console.log(event);
switch (event.action) {
case 'getUrlScheme': {
return getUrlScheme(event.options)
}
}
return 'action not found'
}
async function getUrlScheme(options) {
return cloud.openapi.urlscheme.generate({
jumpWxa: {
path: '/pages/index/product_info', // <!-- replace -->
query: '',
},
// 如果想不过期则置为 false,并可以存到数据库
isExpire: true,
// 一分钟有效期
expireTime: parseInt(Date.now() / 1000 + 3600),
})
}