我正在尝试做的事情:我的端点返回客户端数据,并提供返回上次调用更改后的数据的功能。因此,我需要存储时间戳和类似请求的哈希值的数据-因此,下次我将提供时间戳并仅接收最新数据。
出于这些目的,我将使用内置的实用程序StoreClient。但是据我了解,它将操作secret值来访问我存储的数据。而且,如果客户使用我的应用程序使用相同的机密创建几个Zaps,它们的数据将不会分离,结果,我将遇到问题。
我决定为此使用secret+ZapId
,似乎合乎逻辑,但据我所知,无法访问。
对于REST挂钩,可以在订阅挂钩中获取Zap ID-但这是完全不同的,不适合我的情况。
问题:
Zapier开发人员平台仅具有此用例的功能:z.cursor
(docs)。
想法是,您可以存储在触发器运行期间持续存在的任意数据。 zapier平台负责将数据范围界定到每个单独的zap。
这是一个粗糙的示例(从文档中复制):
const perform = async (z, bundle) => {
let cursor = await z.cursor.get(); // string | null;
const response = await z.request(
'https://someEndpoint',
{
// if cursor is null, it's sent as an empty query
// param and should be ignored by the server
params: { cursor: cursor }
}
);
// we successfully got page 1, should store the cursor in case the user wants page 2
await z.cursor.set(response.nextPage); // you would hash whatever data you want to store
return response.items;
};