How to Redirect after get request

Please take a look at my workflow:

The end of this workflow returns a url string. I want to redirect the browser to this url but have no idea how. Can someone polease help?

Welcome @kenny1! You’ll want to use the $respond function to return that data, setting the status to 301, 302, or whatever redirect code makes sense for your use case:

  status: 302,
  headers: { "my-custom-header": "value" },
  body: { message: "My custom response" }, // This can be any string, object, Buffer, or Readable stream

Here’s my current code. Not sure how to apply the $respond function

import axios from "axios";

// Make an HTTP GET request using axios
const resp = await axios({
  method: "GET",
  url: ``,
  params: {
// Retrieve just the data from the response
const { data } = resp;
return data;

the above code returns url text string from steps.get_sheets.$return_value
I need to redirect to that URL

You’ll essentially want to replace the last line:

return data;

with this:

  status: 302,
  headers: { "Location": data }

When a web browser loads your workflow’s HTTP endpoint, that will signal to your browser that you’d like to redirect the browser to the URL returned in the Location.

That worked but now the app that is sending the post request to pipedream is returning this error:

Status Code: 400

Body: Internal error waiting for $respond, workflow may have executed succesfully

Could you do me a favor and click the Share button at the top-right of your workflow, and share it with I’d like to take a look at the whole workflow.

Ok, shared. Here’s the link:

Thanks. I didn’t see anything obviously wrong, and when I copied the workflow and replaced your custom endpoints with some of my own, it worked.

Could you try copying the workflow by clicking in the three-lined icon at the top-right?

Screen Shot 2021-10-17 at 9.08.11 PM

This will generate a new workflow with a new HTTP endpoint. Make an HTTP request against the new workflow and let me know if that works.

If it doesn’t, I’ll dig in more first-thing tomorrow morning with my team.

I sent post request to copy this workflow link, it returned a 404 error. Seems like my post request into pipedream is timing out before $response can finish running.

So when i used return data the app initiating the workflow returned a 200 ok. But when i used the $respond (to redirect) the initiating app returned a 404. Any ideas?

Is there another method for redirecting to the url returned by get response?

Very late to this but I found it whilst researching the same problem. In Nov. 2022, this works:

         * Set the redirect URL
        let redirectUrl = "";
        //Assume a boolean variable in the code is tracking errors.
        if (hasErrors) {

            redirectUrl = "";

        await $.respond({
            headers: { "Location": redirectUrl },
            status: 301
1 Like