【问题标题】:Zapier StoreClient undefinedZapier StoreClient 未定义
【发布时间】:2019-12-25 19:06:24
【问题描述】:

我正在尝试存储调用之间的状态,类似于此处的文档:https://zapier.com/apps/code/help#code-examples

但是,我尝试从 Zap 运行代码,我得到:

StoreClient 没有定义

文档指出我不需要任何东西来使用 StoreClient:“不需要它 - 它是在您的代码环境中预先导入的。”

我使用的是最新版本的 zapier-platform-core (8.3.0)。 我正在使用上面链接示例中的确切代码。

 const count = await store.get('some counter')
 const newCount = (count || 0) + 1;
 await store.set('some counter', count);
 return {count: newCount};

【问题讨论】:

    标签: zapier zapier-cli


    【解决方案1】:

    David 来自 Zapier 平台团队。好问题!

    根据文档,这有点不清楚 - StoreClient 仅在代码应用程序中可用(又名 Code by Zapier)。如果您使用zapier-platform-core,则您正在创建一个cli 应用程序,它是一个普通的node.js 环境。如果您想在 cli 应用程序中与 Storage by Zapier 进行交互,您可以使用网站上的文档:https://store.zapier.com。即:

    {
      "how does it work?": {
        "always provide either `?secret=12345` or `X-Secret: 12345`": "",
        "GET /api/secret": [
          "will return a random secret for you to use if you need one."
        ],
        "GET /api/records": [
          "will return a full object of all values stored by default.",
          "you can also specify only the keys you want via the",
          "querystring like`?key=color&key=age`."
        ],
        "POST /api/records": [
          "provide a body with a json object with keys/values you want",
          "to store like `{\"color\": \"blue\", \"age\": 29}`."
        ],
        "DELETE /api/records": ["completely clear all the records in this account"],
        "PATCH /api/records": [
          "A data with a particular schema needs to be received.",
          "The schema specifies which action to do and with what parameters.",
          "For example {\"action\": \"increment_by\", \"data\": {\"key\": \"<key_name>\", \"amount\": 1}} to increment the value specified by \"key\"."
        ]
      }
    }
    
    

    可以使用标准 z.request 向这些端点发出请求,此处有详细记录:https://github.com/zapier/zapier-platform/tree/master/packages/cli#making-http-requests

    【讨论】:

      猜你喜欢
      • 2020-10-11
      • 2020-02-19
      • 2019-12-24
      • 2019-08-23
      • 1970-01-01
      • 2017-12-20
      • 2019-10-14
      • 2021-08-06
      • 1970-01-01
      相关资源
      最近更新 更多