<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [FetchAndSaveHooks](./x-components.fetchandsavehooks.md)

## FetchAndSaveHooks interface

Options to use with the [createFetchAndSaveActions()](./x-components.createfetchandsaveactions.md) factory.

**Signature:**

```typescript
export interface FetchAndSaveHooks<Context extends XActionContext<StatusState, object, StatusMutations, object>, Request, Response> 
```

## Properties

|  Property | Modifiers | Type | Description |
|  --- | --- | --- | --- |
|  [fetch](./x-components.fetchandsavehooks.fetch.md) |  | (context: Context, request: Request) =&gt; Promise&lt;Response&gt; | Retrieves and returns asynchronously some data. |
|  [onCancel?](./x-components.fetchandsavehooks.oncancel.md) |  | () =&gt; void | _(Optional)_ Synchronous callback executed when the request is cancelled. This can happen mainly for two reasons: - The [FetchAndSaveActions.cancelPrevious](./x-components.fetchandsaveactions.cancelprevious.md) action is dispatched. - A new [FetchAndSaveActions.fetchAndSave](./x-components.fetchandsaveactions.fetchandsave.md) is dispatched before the previous one was resolved. |
|  [onError?](./x-components.fetchandsavehooks.onerror.md) |  | (error: unknown) =&gt; void | _(Optional)_ Asynchronous callback executed when either the [FetchAndSaveHooks.fetch](./x-components.fetchandsavehooks.fetch.md) or [FetchAndSaveHooks.onSuccess](./x-components.fetchandsavehooks.onsuccess.md) methods fail. |
|  [onSuccess](./x-components.fetchandsavehooks.onsuccess.md) |  | (context: Context, response: Response) =&gt; void | Asynchronous callback executed when the [FetchAndSaveHooks.fetch](./x-components.fetchandsavehooks.fetch.md) is performed successfully. |

