TypeError: Failed to fetch when calling fetch from the Javascript action

Support
  • I am running a javascript action that attempts to do a GET request using fetch. I am using the exact example that shows up in documentation for that rule.

    async function getPost(id) {
      return await fetch(`https://jsonplaceholder.typicode.com/posts/` + id)
        .then((res) => res.json());
    }
    
    [[POST]] = await getPost(1);
    

    However, when I call this code it always fails with the message "TypeError: Failed to fetch". Does anyone know what I'm doing wrong?

  • 0 Votes
    1 Posts
    479 Views
  • BAS fails

    Support
    0 Votes
    5 Posts
    1207 Views
  • 0 Votes
    2 Posts
    1222 Views
  • 0 Votes
    15 Posts
    5250 Views
  • "Wait for human action" addon..

    Support
    1 Votes
    6 Posts
    3036 Views