<!-- 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

<table><thead><tr><th>

Property


</th><th>

Modifiers


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

[fetch](./x-components.fetchandsavehooks.fetch.md)


</td><td>


</td><td>

(context: Context, request: Request) =&gt; Promise&lt;Response&gt;


</td><td>

Retrieves and returns asynchronously some data.


</td></tr>
<tr><td>

[onCancel?](./x-components.fetchandsavehooks.oncancel.md)


</td><td>


</td><td>

() =&gt; void


</td><td>

_(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.


</td></tr>
<tr><td>

[onError?](./x-components.fetchandsavehooks.onerror.md)


</td><td>


</td><td>

(error: unknown) =&gt; void


</td><td>

_(Optional)_ Asynchronous callback executed when either the [FetchAndSaveHooks.fetch](./x-components.fetchandsavehooks.fetch.md) or [FetchAndSaveHooks.onSuccess](./x-components.fetchandsavehooks.onsuccess.md) methods fail.


</td></tr>
<tr><td>

[onSuccess](./x-components.fetchandsavehooks.onsuccess.md)


</td><td>


</td><td>

(context: Context, response: Response) =&gt; void


</td><td>

Asynchronous callback executed when the [FetchAndSaveHooks.fetch](./x-components.fetchandsavehooks.fetch.md) is performed successfully.


</td></tr>
</tbody></table>

