【问题标题】:Logging variables defined in output/input记录在输出/输入中定义的变量
【发布时间】:2016-04-04 19:18:18
【问题描述】:

我对这个文档有点困惑。我可能读错了,但文档说您可以根据您在来自触发器给出的文本字段中定义的内容将变量添加到 input 对象。根据这张图片,用户定义了 3 个输入变量bodyreceiveDatesubject
(来源:cachefly.net

但是在代码中,它们引用了一个名为 plainBody 的变量,该变量尚未定义。这将如何运作?

是否有一个我可以注销的对象,它包含我的触发器中出现的每个字段?还是我必须使用输入字段将它们定义为输入?

编辑:我也无法让任何z 库工作。根据这个文档:https://zapier.com/developer/documentation/v2/built-functions-tools/#available-libraries我应该能够做类似的事情

// let's call http://httpbin.org/get?hello=world with an extra header
var request = {
  method: 'GET',
  url: 'http://httpbin.org/get',
  params: {
    hello: 'world'
  },
  headers: {
    Accept: 'application/json'
  },
  auth: null,
  data: null
};

// perform asynchronously
z.request(request, function(err, response){
  console.log('Status: ' + response.status_code);
  console.log('Headers: ' + JSON.stringify(response.headers));
  console.log('Content/Body: ' + response.content);
});

但我收到一条错误消息,上面写着z is not defined theFunction

【问题讨论】:

    标签: javascript zapier


    【解决方案1】:

    这里是 Zapier 的开发者!

    您在input 对象中提供的数据是您的代码运行时将提供给您的所有数据;不幸的是,该示例屏幕截图中似乎存在拼写错误(该条件中的两个检查都应针对input.body)。

    您引用的文档链接适用于 Zapier Developer Platform,这是您将自己的应用程序添加到 Zapier 以供其他人使用的方式。这也在后端运行 Javascript,所以我看到这两个东西很容易混淆!

    您正在寻找与running code in a Zap 相关的文档。

    要直接回答您的问题,Zapier 的代码 应用程序中没有可用的z 对象。要发出 HTTP 请求,您需要使用 fetch 库:

    fetch('http://example.com/')
      .then(function(res) {
        return res.text();
      }).then(function(body) {
        var output = {id: 1234, rawHTML: body};
        callback(null, output);
      }).catch(function(error) {
        callback(error);
      });
    

    该代码取自链接文档中的Introductory HTTP Example

    希望有帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-10
      • 2018-01-06
      • 2019-05-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多