Skip to content

Commit e60bde1

Browse files
committed
docs: adds links and other helpful tips
1 parent d3e6d16 commit e60bde1

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

16/umbraco-cms/customizing/foundation/fetching-data/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Here is a quick overview of the two options for you to compare:
2525
| Error Handling | Manual | Built-in |
2626
| Type Safety | No | Yes |
2727
| Request Cancellation | Yes (via AbortController) | Yes (via AbortController) |
28-
| Recommended Use Case | Standard requests | Complex or frequent requests|
28+
| Recommended Use Case | Common requests | Complex or frequent requests |
2929

3030
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.
3131

@@ -39,6 +39,8 @@ The Umbraco HTTP Client is a wrapper around the Fetch API that provides a more c
3939

4040
## Handle Requests
4141

42+
Once you have chosen a method to fetch data, the next step is to handle the execution of requests. This includes managing errors, refreshing tokens, and ensuring proper authentication.
43+
4244
## [Executing Requests](try-execute.md)
4345

4446
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.
@@ -47,7 +49,7 @@ Executing the request is the next step after fetching data. You can use the `try
4749

4850
### [Custom Generated Client](custom-generated-client.md)
4951

50-
It can be useful to generate a custom client for your API. This can save you a lot of time and effort when working with custom API controllers.
52+
For advanced scenarios, you can generate a custom client for your API using tools like **@hey-api/openapi-ts**. This approach is ideal when working with custom API controllers or when you need type-safe, reusable client code.
5153

5254
## Further Reading
5355

16/umbraco-cms/customizing/foundation/fetching-data/custom-generated-client.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ npx openapi-ts generate --url https://example.com/openapi.json --output ./my-cli
3030

3131
This will generate a TypeScript client in the `./my-client` folder. You can then import the client into your project and use it to make requests to the Management API.
3232

33+
To learn more about OpenAPI and how to define your API specification, visit the [OpenAPI Documentation](https://swagger.io/specification/).
34+
3335
## Connecting to the Management API
3436

3537
You will need to set up a few configuration options in order to connect to the Management API. The following options are required:

16/umbraco-cms/customizing/foundation/fetching-data/fetch-api.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,18 @@ console.log(data);
8080
The example assumes that you have a valid authentication token. You can replace this with your own token as needed. Read more about authentication in the [Security](../../../implementation/security.md) article.
8181
{% endhint %}
8282
83+
{% hint style="warning" %}
84+
When using the Fetch API with `UMB_AUTH_CONTEXT`, you need to handle token expiration errors manually. If the token is expired, the request will return a 401 error. You will need to refresh the token or prompt the user to log in again.
85+
{% endhint %}
86+
8387
Why Use **UMB_AUTH_CONTEXT**?
8488
8589
- Simplifies Token Management: Automatically retrieves and refreshes tokens when needed.
8690
- Aligns with Best Practices: Ensures your requests are authenticated in a way that integrates seamlessly with the Backoffice.
8791
- Reduces Errors: Avoids common pitfalls like expired tokens or incorrect headers.
8892
8993
{% hint style="info" %}
90-
The **UMB_AUTH_CONTEXT** is only available in the Backoffice. For external applications, you will need to manage tokens manually or use an API user. Read more about API users in the [API Users article](../../../fundamentals/data/users/api-users.md).
94+
The **UMB_AUTH_CONTEXT** is only available in the Backoffice. For external applications, you will need to manage tokens manually or use an API user. Read more about API users in the [API Users](../../../fundamentals/data/users/api-users.md) article.
9195
{% endhint %}
9296
9397
## Management API Controllers

16/umbraco-cms/customizing/foundation/fetching-data/try-execute.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ The `tryExecute` function takes the context of the current class or element as t
3535
The above example requires a host element illustrated by the use of `this`. This is typically a custom element that extends the `UmbLitElement` class.
3636
{% endhint %}
3737

38-
It is recommended to always use the `tryExecute` function to wrap HTTP requests.
38+
It is recommended to always use the `tryExecute` function to wrap HTTP requests. It simplifies error handling, manages token expiration, and ensures a consistent user experience in the Backoffice.
3939

4040
### Disable Notifications
4141

@@ -47,9 +47,9 @@ tryExecute(this, request, {
4747
});
4848
```
4949

50-
### Cancelling requests
50+
### Cancelling Requests
5151

52-
The `tryExecute` function also supports cancelling requests. This is useful if you want to cancel a request that is taking too long or if the user navigates away from the page. You can cancel a request by using the [AbortController API](https://developer.mozilla.org/en-US/docs/Web/API/AbortController). The `AbortController` API is a built-in API in modern browsers that allows you to cancel requests. You can use it directly with tryExecute:
52+
The `tryExecute` function also supports cancelling requests. This is useful in scenarios where a request is taking too long, or the user navigates away from the page before the request completes. You can cancel a request by using the [AbortController API](https://developer.mozilla.org/en-US/docs/Web/API/AbortController). The `AbortController` API is a built-in API in modern browsers that allows you to cancel requests. You can use it directly with tryExecute:
5353

5454
```javascript
5555
const abortController = new AbortController();

0 commit comments

Comments
 (0)