【问题标题】:Zapier POST with error "body used already for"Zapier POST 错误“正文已用于”
【发布时间】:2018-11-16 20:39:09
【问题描述】:

基本上逐字遵循code example,但尝试使用fetch发出POST请求

fetch('YOUR URL HERE', { method: 'POST', 'body': content })
    .then(function (res) {
        console.log(res.text());
        return res.text();
    })
    .then(function (plain) {
        var output = { okay: true, raw: plain };
        callback(null, output);
    })
    .catch(callback);

导致愤怒的红色框:

我们在发送您的测试时遇到了问题。请再试一次。错误: 错误:body 已用于https://YOURURLHERE

不知道是什么意思?

【问题讨论】:

    标签: fetch-api zapier


    【解决方案1】:

    ...然后我意识到这不是 Zapier 问题,而是fetch 问题。

    Google 说这是因为我在 promise 中所做的,通过尝试将 res 流作为文本读取两次(注意两个 res.text() 调用)。 p>

    (在大约 2 分钟的时间里,我忽略了问题中我认为不重要的细节,console.log 行是罪魁祸首)

    【讨论】:

    • 没错!您可以使用console.log(plain) 获得相同的结果
    猜你喜欢
    • 2016-11-28
    • 2015-12-14
    • 2019-07-17
    • 2017-12-14
    • 2016-04-11
    • 2021-12-05
    • 2023-01-19
    • 2021-06-20
    相关资源
    最近更新 更多