我正在尝试编写一个可以在任何新数据上运行的 zapier 触发器。我正在尝试使用套接字或 Redis 来完成此操作。在这个例子中,我将使用带有 zapier-cli 的套接字。如果有人代码将我指向一个类似的示例,这将是一个很大的帮助,请提供帮助。
const listRecipes = (z, bundle) => {
// import SocketIOClient from 'socket.io-client';
const SocketIOClient = require('socket.io-client')
// z.console.log('hello from a console log!')
// const promise = z.request(
// 'http://57b20fb546b57d1100a3c405.mockapi.io/api/recipes'
// )
// return promise.then(response => response.json)
socket = SocketIOClient(SocketURL);
socket.on(`msg-channel/53`, (data) => {
// trigger when this achieved
});
}
module.exports = {
key: 'recipe',
noun: 'Recipe',
display: {
label: 'New Recipe',
description: 'Trigger when a new recipe is added.'
},
operation: {
perform: listRecipes,
sample: {
id: 1,
createdAt: 1472069465,
name: 'Best Spagetti Ever',
authorId: 1,
directions: '1. Boil Noodles\n2.Serve with sauce',
style: 'italian'
}
}
}
谢谢