> For the complete documentation index, see [llms.txt](https://shinyobjectlabs.gitbook.io/fetch-js/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://shinyobjectlabs.gitbook.io/fetch-js/actions/schema.md). Agents can also search and read this documentation through its [MCP server](https://shinyobjectlabs.gitbook.io/fetch-js/~gitbook/mcp).

# Schema

## Example

Below is an example of a full schema with every action option and event including callback methods.

```javascript
{
  options: {
    url: 'https://jsonplaceholder.typicode.com/todos/',
    method: 'post', // *GET, POST, PUT, DELETE
    headers: [{
      key: 'Content-Type',
      value: 'application/json'
    }],
    body: [{
      key: 'title',
      value: 'My todo item'
    }],
    mode: "cors", // no-cors, *cors, same-origin
    cache: "default", // *default, no-cache, reload, force-cache, only-if-cached
    credentials: "same-origin", // include, *same-origin, omit
    redirect: "follow", // manual, *follow, error
    referrerPolicy: "no-referrer-when-downgrade", // no-referrer, *no-referrer-when-downgrade, origin, 
  },
  events: {
    onRequestInit: {
      callback: async (fetchOptions, triggerEl) => {
        console.log(fetchOptions)
      }
    },
    onSuccess: {
      redirectUrl: null, // url e.g. https://example.com
      showElement: null, // element id e.g. #myElement
      hideElement: null, // element id
      callback: async (response, data) => {
        console.log(data)
      }
    }
    onError: {
      redirectUrl: null, // url
      showElement: null, // element id
      hideElement: null, // element id
      callback: async (response, data) => {
        console.log(data)
      }
    }
  }
}
```
