调试 console都正常,但是return后,客户端调用的就是获取不到
客户端代码:
async getToken() {
const wenxinObj = uniCloud.importObject('aio-wenxin')
try {
const res = await wenxinObj.getWenxinToken()
console.log('page callapi token =', res)
if(res.errCode==0) {
this.accessToken = res.data
}
} catch (e) {
console.log(e.errCode)
console.log(e.errMsg)
}
},
云对象代码:
async function getWenxinToken() {
let result = null
const db = uniCloud.database();
try {
let res = await db.collection('token').where({
_id: '63874807f43e6046ed553b2b'
}).get({
getOne: true
})
let token = res.data[0].astoken
console.log('getWenxinToken res = ', res, token)
result = {
errCode: 0,
errMsg: '成功',
data: token
}
} catch (e) {
console.log('get wenxintoken error = ', e)
result = {
errCode: -1,
errMsg: '查询失败'
}
}
return result
}
2 个回复
DCloud_uniCloud_CRL
云对象_after方法有没有对返回的数据进行处理?
呆狗的一生 - 呆狗的一生
token
表是否有astoken
字段另外,
get
方法参数仅jql
语法支持