'use strict';
const db = uniCloud.database()
exports.main = async (event, context) => {
//event为客户端上传的参数
const collection = db.collection('user')
//根据官网示例调用云函数
let callFunctionResult = await uniCloud.callFunction({
name: "queryUser",
data: {
mobilePhone:event.mobilePhone
}
})
console.log('callFunctionResult',callFunctionResult)
return event
};
--------------报错如下:
[uniappCloud] 17:28:40.513 [腾讯云:solo-cloud]运行状态:失败
[uniappCloud] 17:28:40.514 [腾讯云:solo-cloud]返回结果:{"errorCode":-1,"errorMessage":"user code exception caught","stackTrace":"errCode: FUNCTIONS_EXECUTE_FAIL | errMsg: errCode: SIGN_PARAM_INVALID | errMsg: signature calculated is different from client signature\nError: errCode: SIGN_PARAM_INVALID | errMsg: signature calculated is different from client signature\n at t.then.t (/var/user/@dcloudio/serverless/lib/tcb/uni-cloud.js:1:1182)\n at \u003canonymous\u003e\n at process._tickCallback (internal/process/next_tick.js:188:7)\nError: errCode: FUNCTIONS_EXECUTE_FAIL | errMsg: errCode: SIGN_PARAM_INVALID | errMsg: signature calculated is different from client signature\nError: errCode: SIGN_PARAM_INVALID | errMsg: signature calculated is different from client signature\n at t.then.t (/var/user/@dcloudio/serverless/lib/tcb/uni-cloud.js:1:1182)\n at \u003canonymous\u003e\n at process._tickCallback (internal/process/next_tick.js:188:7)\n at t.then.t (/var/user/@dcloudio/serverless/lib/tcb/uni-cloud.js:1:1182)\n at \u003canonymous\u003e\n at process._tickCallback (internal/process/next_tick.js:188:7)"}
[uniappCloud] 17:28:40.514 [腾讯云:solo-cloud]运行日志:
Error: errCode: FUNCTIONS_EXECUTE_FAIL | errMsg: errCode: SIGN_PARAM_INVALID | errMsg: signature calculated is different from client signature
Error: errCode: SIGN_PARAM_INVALID | errMsg: signature calculated is different from client signature
at t.then.t (/var/user/@dcloudio/serverless/lib/tcb/uni-cloud.js:1:1182)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
at t.then.t (/var/user/@dcloudio/serverless/lib/tcb/uni-cloud.js:1:1182)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
[uniappCloud] 17:28:40.514 [腾讯云:solo-cloud]运行报告:计费时间:200ms 计费时间:125ms 运行内存:34.5MB
soloEmperor (作者)
'use strict';
const db = uniCloud.database()
const dbCmd = db.command
exports.main = async (event, context) => {
console.log('event',event)
let res = await db.collection('user').where({
mobilePhone: dbCmd.eq(event.mobilePhone)
}).get()
if (res.data) {
console.log('data',res.data)
return res;
} else {
console.log('no-data')
return {
code:'400',
data:{},
msg:'找不到该用户'
}
}
};
----这是queryUser的代码,大致是用mobilePhone作为查询条件去查询
2020-04-15 13:40
DCloud_uniCloud_WYQ
回复 soloEmperor: 有使用signInWithTicket什么的吗
2020-04-15 15:32
soloEmperor (作者)
回复 DCloud_uniCloud_WYQ: 还没。刚开始写云函数增删改查之类的,还没到这一步来
2020-04-15 17:56
叶隐霜
回复 soloEmperor: 兄弟,你问题解决了吗,我碰到一样的问题了
2020-05-01 10:44
soloEmperor (作者)
回复 叶隐霜: 没,不能调,只能又继续写方法
2020-05-08 15:52