Creating a Action

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

Arguments

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>

Last updated