<script>

<script> contains the body of an asynchronous JavaScript function.

Why use it

Use it for business logic that needs normal JavaScript features without hiding the surrounding workflow structure.

Common use cases

  • Transform JSON data.
  • Use conditions and loops inside one durable step.
  • Await Fetch, local modules, or built-in services.
  • Run observational lifecycle or provider logic.

Syntax

WOML
<script>
  const response = await services.http.request({
    url: "https://api.example.com/orders",
    method: "POST",
    json: context.payload
  }, { name: "create-order" });

  return response.data;
</script>

Rules and behavior

  • It accepts no attributes.
  • The body may use await, conditions, loops, exceptions, Fetch, modules, and services without a function wrapper.
  • A step publishes data only by returning a JSON-compatible value.
  • Context mutation, locals, and worker globals do not persist.
  • The first literal </script> ends the body, even inside a JavaScript string or comment.