Navigation

Call a Service Action

On this page

  • Overview
  • Call from a Function

You can call actions associated with a service from Realm Functions, including incoming webhooks and triggers, or directly from a connected client application. Each service action is available as a method on its respective service client.

Note

You must configure a service rule that enables an action before you can call it.

The examples in this section demonstrate calling the post() action from the HTTP Service. Each service action follows a similar pattern but has distinct parameters. For details on the parameters and usage of a specific action, refer to that action's reference page.

To call a service action from a function:

  1. Instantiate a service client from application context using the context.services global variable.
  2. Call the method associated with the action.
const http = context.services.get("myHttpService");
http.post({
"url": "https://www.example.com",
"headers": { "Content-Type": ["application/json"] },
"body": { "msg": "Hello from a service action!" }
})
.then(() => "Successfully sent the post request!")
Give Feedback

On this page

  • Overview
  • Call from a Function