评论

signature calculated is different from client signature;

signature calculated is different from client signature;

遇到一个问题,是在云函数端的错误。
代码是这样的,在云函数端更改一个数据记录。

var  handleGoods =function(goods,storenum){
  var _ = db.command;
 return db.collection('goods').doc(goods._id).update({
    data:{
      store_num:_.inc(storenum*-1),
      sale_num:_.inc(storenum)
    }
  });
}

结果是

Error: errCode: -501001 resource system error | errMsg: signature calculated is different from client signature; 
    at new CloudSDKError (/Users/skymxc/Documents/project/WeChat/shop/cloudfunctions/handleOrder/node_modules/wx-server-sdk/index.js:4332:28)
    at Object.returnAsCloudSDKError (/Users/skymxc/Documents/project/WeChat/shop/cloudfunctions/handleOrder/node_modules/wx-server-sdk/index.js:4384:16)
    at Object.checkError (/Users/skymxc/Documents/project/WeChat/shop/cloudfunctions/handleOrder/node_modules/wx-server-sdk/index.js:1401:23)
    at DocumentReference.<anonymous> (/Users/skymxc/Documents/project/WeChat/shop/cloudfunctions/handleOrder/node_modules/wx-server-sdk/index.js:1334:41)
    at step (/Users/skymxc/Documents/project/WeChat/shop/cloudfunctions/handleOrder/node_modules/tslib/tslib.js:133:27)
    at Object.next (/Users/skymxc/Documents/project/WeChat/shop/cloudfunctions/handleOrder/node_modules/tslib/tslib.js:114:57)
    at fulfilled (/Users/skymxc/Documents/project/WeChat/shop/cloudfunctions/handleOrder/node_modules/tslib/tslib.js:104:62)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

返回的错误是 signature calculated is different from client signature; 签名和客户端不同
因为是在云函数端,也不存在权限问题吧。很是不解。

有没有大神帮忙看一下子,万分感谢。

点赞 0
收藏
评论

1 个评论

  • 中海
    中海
    02-25
    解决方法:将依赖的wx-server-sdk通过NPM升级到最新版本。
    
    npm update wx-server-sdk --save
    
    确保云函数下的package.json为最新版本
    {
      "dependencies": {
        "wx-server-sdk""^2.3.3"
      }
    }
    


    02-25
    赞同
    回复
登录 后发表内容