Firebase Cloud功能在本地运行,但不在云上运行

时间:2018-02-22 23:55:15

标签: javascript firebase google-cloud-functions

我在笔记本电脑上使用Firebase控制台来运行此功能,它运行正常。我部署到Firebase并触发它,但它给了我一个'未处理的拒绝'错误。任何建议将不胜感激。谢谢!

exports.updateItems = functions.database.ref('/update').onUpdate(event => {
  return superagent
    .get(zohoItemsRef + 'items?' + zohoToken + zohoOrg)
    .query({
      authtoken: zohoToken,
      organization_id: zohoOrg
    })
    .set('cache-control', 'no-cache')
    .then(res => {
      res.body.items.forEach(function(item) {
        if (item.status === 'active') {
          var itemData = {
            name: item.name,
            price: item.rate,
            category: item.cf_product_category,
            partNumber: item.part_number
          }
          if (item.cf_quick_pick) {
            itemData.quickMenu = item.cf_quick_pick
          }
          itemRef.doc(item.item_id).set(itemData)
        }
      })
    })
    .catch(e => {
      console.log(e)
    })
})

0 个答案:

没有答案
相关问题