订阅消息发不出去
发布于 6 年前 作者 jieyao 4871 次浏览 来自 官方Issues

https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/subscribe-message/subscribeMessage.send.html

const cloud = require('wx-server-sdk')
cloud.init()
exports.main = async (event, context) => {
  // const wxContext = cloud.getWXContext(),
  try {
    const result = await cloud.openapi.subscribeMessage.send({
      touser: 'oJpod5PFl0DyJdSTWk8ksqbX7ZcQ',
      page: 'pages/index/index',
      data: {
        time1: {
          value: '2020-12-31'
        },
        thing3: {
          value: '麻辣酱'
        },
        thing4: {
          value: '测试'
        },
        number2: {
          value: '30'
        }
      },
      templateId: 'tydEgW60mqiPDmY4Pj03qdUYuxcEtb-PKzH_URKmOCU'
    })
    console.log(result)
    return result
  } catch (err) {
    console.log(err)
    return err
  }
}

返回的结果是这样的,谁能帮忙解读一下我错在哪里了吗?

msgERROR RequestId:deba5fc1-2f9a-11ea-90a7-5254002fa145 Result:{“errCode”:1,“errMsg”:“user code exception caught”,“stackTrace”:“Unexpected token try”}

Error: errCode: -404011 cloud function execution error | errMsg: cloud.callFunction:fail requestID , cloud function service error code -504002, error message Unexpected token try; at cloud.callFunction api; 

1 回复

已解决。是参数格式不对

回到顶部