Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zapier POST with error "body used already for"

Basically following the code example verbatim, but trying to make a POST request with fetch

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);

Results in angry red box with:

We had trouble sending your test through. Please try again. Error: Error: body used already for: https://YOURURLHERE

Not sure what it means?

like image 649
drzaus Avatar asked Jun 07 '18 03:06

drzaus


1 Answers

...and then I realized it's not a Zapier question, but a fetch issue.

Google says it's because of what I'm doing in the promise, by trying to read the res stream as text twice (note the two res.text() calls).

(for about 2 minutes I had omitted what I thought was an unimportant detail from the question, the console.log line which was the culprit)

like image 137
drzaus Avatar answered Oct 09 '22 05:10

drzaus