How do I return data from an action?

I followed the documentation and set up my action with the following TOML:

[[extensions]]
name = ...
handle = ...
type = "flow_action"
schema = "./schema.graphql"
return_type_ref = "Result"

With the following schema:

type Result {
  message: String!
}

The runtime_url returns:

export const action = async ({ request }) => {
  const { payload, admin } = await authenticate.flow(request);
  console.log({payload})
  return json({ return_value: { message: "Hello world!" } });
}

However, when the flow is run, I get:

Please advise on how I need to configure the files?

Thanks.

You are returning { return_value { message: “” }} instead of { message: “”}

I still get the same null output returning json({message:“”}) or just the object.

export const action = async ({ request }) => {
  const { payload, admin } = await authenticate.flow(request);

  console.log("got here");
  return json({ message: "" });
};

Are you using that message in the Workflow. As the info on that field states, if a value isn’t used, then Flow doesn’t store it. So you need to add it to an action after Run code like “Log output”. You can also use console.log if you want to see it.

return json({ return_value: { message: "Hello" } });

Thanks for the reply, Paul. In the end, the correct return is with “return_value” AND what you said about adding a Log Output block.

I think the documentation can be better in my opinion! The error wasn’t the most useful.

I did it but i am still not seeing any data. in run code its not identifying the response of the previous action as well as even when i am returning in proper format it never shows up the data idk whats the issue here.

Are you replaying in the wrong thread? The original post is from March