service

Fetch information from an external service

Definition

any service(string $service, string $operation, any $data)

Fetches information from a connected service. The service needs to first be defined under Connected services.

Parameters

string $service

Name of the service.

string $operation

Name of the operation.

any $data

Data to send.

Returns

any

The response body of an external service.

Examples

The setup of the external service is relevant here as well:

{
  "post": {
    "id": "3"
  }
}
{
	a: service('ExampleService', 'getByID', {
		id: post.id
	}),
	b: service('ExampleService', 'postToDirectory', {
        "directory": 'posts',
        "userId": `7`,
        "title": 'ExampleTitle',
        "body": 'ExampleText'
	})
}
{
  "a": {
    "userId": 1,
    "id": 3,
    "title": "ea molestias quasi exercitationem repellat qui ipsa sit aut",
    "body": "et iusto sed quo iure\nvoluptatem occaecati omnis eligendi aut ad\nvoluptatem doloribus vel accusantiu... (TRUNCATED)"
  },
  "b": {
    "userId": 7,
    "title": "ExampleTitle",
    "body": "ExampleText",
    "id": 101
  }
}