|
| 1 | +--- |
| 2 | +description: Learn how to request data when extending the Backoffice. |
| 3 | +--- |
| 4 | + |
1 | 5 | # Fetching Data |
2 | 6 |
|
3 | | -Learn how to request data when extending the Backoffice. |
| 7 | +## Fetch Data Through HTTP |
| 8 | + |
| 9 | +There are two main ways to fetch data through HTTP in the Umbraco Backoffice: using the Fetch API or the Umbraco HTTP client. The Fetch API is a modern way to make network requests in JavaScript, while the Umbraco HTTP client is a wrapper around the Fetch API. That provides a more convenient way to make network requests. |
| 10 | + |
| 11 | +For most scenarios, we recommend using the Umbraco HTTP client provided by Umbraco. The Fetch API is an alternative for simpler use cases. Here is a quick overview of the two options for you to compare: |
| 12 | + |
| 13 | + | Feature | [Fetch API](fetch-api.md) | [Umbraco HTTP Client](http-client.md) | |
| 14 | +|------------------------|-------------------------------|------------------------------| |
| 15 | +| Authentication | Manual | Automatic | |
| 16 | +| Error Handling | Manual | Built-in | |
| 17 | +| Type Safety | No | Yes | |
| 18 | +| Request Cancellation | Yes (via AbortController) | Yes (via AbortController) | |
| 19 | +| Recommended Use Case | Standard requests | Complex or frequent requests| |
4 | 20 |
|
5 | | -## [Fetch API](fetch-api.md) |
| 21 | +Once you have decided which option to use, you can read more about how to use it below. After that, you can read about how to work with the data you receive from the server. |
| 22 | + |
| 23 | +### [Fetch API](fetch-api.md) |
6 | 24 |
|
7 | 25 | The Fetch API is a modern way to make network requests in JavaScript. It provides a more powerful and flexible feature set than the older XMLHttpRequest. |
8 | 26 |
|
9 | | -## [HTTP Client](http-client.md) |
| 27 | +### [HTTP Client](http-client.md) |
10 | 28 |
|
11 | 29 | The HTTP Client is a wrapper around the Fetch API that provides a more convenient way to make network requests. It handles things like request and response parsing, error handling, and retries. |
12 | 30 |
|
| 31 | +## Handle Requests |
| 32 | + |
| 33 | +### [Executing Requests](try-execute.md) |
| 34 | + |
| 35 | +Executing the request is the next step after fetching data. You can use the `tryExecute` function to handle errors and refresh the token if it is expired. |
| 36 | + |
13 | 37 | ## [Working with Data](../working-with-data/README.md) |
14 | 38 |
|
15 | 39 | Once you have the data using one of the methods above, you can read more about how to work with it here. |
0 commit comments