Skip to content

Error in example, double return #22150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
luis-herasme opened this issue May 2, 2025 · 0 comments · Fixed by #22180
Closed

Error in example, double return #22150

luis-herasme opened this issue May 2, 2025 · 0 comments · Fixed by #22180
Assignees
Labels
product:workflows Workflows: https://developers.cloudflare.com/workflows/

Comments

@luis-herasme
Copy link

Example URL(s)

https://developers.cloudflare.com/workflows/build/events-and-parameters/#pass-data-to-a-workflow

Image

Actual Behavior

export default {
  async fetch(req, env) {
    let someEvent = { url: req.url, createdTimestamp: Date.now() };
    // Trigger our Workflow
    // Pass our event as the second parameter to the `create` method
    // on our Workflow binding.
    let instance = await env.MY_WORKFLOW.create({
      id: await crypto.randomUUID(),
      params: someEvent,
    });

    return Response.json({
      id: instance.id,
      details: await instance.status(),
    });

    return Response.json({ result });
  },
};

Expected Behavior

export default {
  async fetch(req, env) {
    let someEvent = { url: req.url, createdTimestamp: Date.now() };
    // Trigger our Workflow
    // Pass our event as the second parameter to the `create` method
    // on our Workflow binding.
    let instance = await env.MY_WORKFLOW.create({
      id: await crypto.randomUUID(),
      params: someEvent,
    });

    return Response.json({
      id: instance.id,
      details: await instance.status(),
    });
  },
};

Additional information

No response

@luis-herasme luis-herasme added the engineering Problems or updates to developers.cloudflare.com website label May 2, 2025
@kodster28 kodster28 added product:workflows Workflows: https://developers.cloudflare.com/workflows/ and removed engineering Problems or updates to developers.cloudflare.com website labels May 2, 2025
kodster28 added a commit that referenced this issue May 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product:workflows Workflows: https://developers.cloudflare.com/workflows/
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants