Comment on page

Creating a Action

To create an action, call $fetch.createAction() passing the name of the action and the actions options.

Arguments

Name
Type
Description
Name
string (snake_case)
The name of the action
Actions options
object
Options used to initialise the request

Example

<script>
$fetch.createAction("my_action", {
options: {
url: 'https://jsonplaceholder.typicode.com/todos/',
method: 'post',
headers: [{
key: 'Content-Type',
value: 'application/json'
}],
body: [{
key: 'title',
value: 'My todo item'
}]
},
events: {
onRequestInit: {
callback: null
},
onSuccess: {
redirectUrl: null,
showElement: null,
hideElement: null,
callback: null
}
onError: {
redirectUrl: null,
showElement: null,
hideElement: null,
callback: null
}
},
});
</script>