Why is the response body empty when using fetch in a HTML app with "Return HTTP Response" step in Pipedream?

This topic was automatically generated from Slack. You can find the original thread here.

Good day all! I’m using a “Return HTTP Response” step to send data from a Data Store and it is working in Pipedream (the response body shows) but in my app (simple HTML) when I’m using fetch the response comes through with no body. Any advice would be greatly appreciated!

Hi , I think your question is a great case for Pipedream bot to help. I’ll pass your question to the Pipedream bot now. Please feel free to ask it any question

Good day all! I’m using a “Return HTTP Response” step to send data from a Data Store and it is working in Pipedream (the response body shows) but in my app (simple HTML) when I’m using fetch the response comes through with no body. Any advice would be greatly appreciated!

It’s possible that the issue is related to how you’re handling the response in your app using the fetch function. When using fetch, you need to parse the response body as JSON or text, depending on the content type. Here’s an example of how to handle a JSON response using fetch: fetch("your-pipedream-endpoint-url") .then((response) => { if (!response.ok) { throw new Error("Network response was not ok"); } return response.json(); }) .then((data) => { console.log(data); }) .catch((error) => { console.error("There was a problem with the fetch operation:", error); }); If you’re still having issues, please provide more information about how you’re using fetch in your app and any error messages you’re encountering.

I think the answer from the bot might not stating the problem.

You can try to select “Return a custom response from your workflow” option in your HTTP trigger

Yes, I did have that option selected. I changed my fetch code to what the bot provided and it is working! Thank you!