> For the complete documentation index, see [llms.txt](https://docs.navigaglobal.com/dashboard-plugin/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.navigaglobal.com/dashboard-plugin/components/agent/actions.md).

# Actions

With actions you can share your functions all around the Dashboard.

Use your actions inside your plugin, or other plugins.

The idea behind `Actions` is to give plugins the power of using other plugins functions and business logic or to share your functions with other plugins

## How to register an Action?

You can register Actions from the `Agent` only, and only once.

You can register one or more actions with `registerAction` method that your Agent will get as long as you extend your Agent from the Agent-Base from Plugin-API

#### Action object:

```javascript
{
    id: '@plugin_bundle-my-awesome-action',
    description: 'My awesome action, to handle awesome things!',
    action: () => {// My awesome action}
}
```

#### register

> You can pass on Action object to registerActions or an array of Action objects

```javascript
import { Plugin } from '@root'

export default class MyAgent extends Plugin.Agent {
    constructor(props) {
        super(props)

        const myActions = [
            {
                id: 'my-logger-action',
                description: 'A logger action to style logs outputs',
                action: this._logger.bind(this)
            },
            {
                id: 'my-fetch-action',
                description: 'A fetch action to handle fetch requests',
                action: this._fetch.bind(this)
            }
        ]

        this.registerActions(actions)
    }

    _logger(message) {
        console.log('=====')
        console.log(message)
        console.log('=====')
    }

    _fetch(url) {
        return new Promise((resolve, reject) => {
            this.request(url).then(resp => resp.json()).then(data => {
                resolve(data)
            }).catch(error => {
                reject(error)
            })
        })
    }
}
```

## How to use an Action?

{% content-ref url="/pages/-MCg1j6bbod6g8V-SkVd" %}
[getAction](/dashboard-plugin/api-and-gui/api/getaction.md)
{% endcontent-ref %}
