收藏
回答

云调用服务端API storage.setUserStorage 报错

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小游戏 Bug storage.setUserStorage 工具 8.0.2 2.2.5

云函数中调用cloud.openapi.storage.setUserStorage

代码如下:

cloud.openapi.storage.setUserStorage({
        openid: update_users.data[i]._id,
        kvList: [{
          key: 'coins',
          value: update_users.data[i].coins,
        }, {
          key'solved',
          value: update_users.data[i].solved.length,
        }]
      })


报错如下:

START RequestId:b8d73340-9806-11eb-b6bd-525400be5245

2021-04-08T01:07:00.552Z (node:7) UnhandledPromiseRejectionWarning: Error: errCode: -604104 illegal source of invocation | errMsg: system error: error code: -604104

at callGeneralOpenAPI (/var/user/node_modules/wx-server-sdk/index.js:486:27)

at process._tickCallback (internal/process/next_tick.js:68:7)

2021-04-08T01:07:00.552Z (node:7) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)

2021-04-08T01:07:00.553Z (node:7) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

2021-04-08T01:07:00.553Z (node:7) UnhandledPromiseRejectionWarning: Error: errCode: -604104 illegal source of invocation | errMsg: system error: error code: -604104

at callGeneralOpenAPI (/var/user/node_modules/wx-server-sdk/index.js:486:27)

at process._tickCallback (internal/process/next_tick.js:68:7)

2021-04-08T01:07:00.553Z (node:7) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)

END RequestId:b8d73340-9806-11eb-b6bd-525400be5245

Report RequestId:b8d73340-9806-11eb-b6bd-525400be5245 Duration:203ms Memory:256MB MemUsage:30.187500MB



config.json中已配置:

"permissions": {

    "openapi": [

      "storage.setUserStorage"

    ]

  },

package.json中已配置:

"dependencies": {

    "wx-server-sdk": "~2.4.0"

  }

开发者工具版本:Stable 1.05.2102010


回答关注问题邀请回答
收藏
登录 后发表内容
问题标签