Http request external endpoint

How can I send an external http request from vaadin fusion frontend?

Hi André, from your JavaScript/TypeScript code you can use the [Fetch API]
(https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch).

There’s nothing special in Fusion when it comes to accessing external resources over HTTP - you can use the same approach as you would use without Fusion.

If you want to make the HTTP requests from the browser, for direct access and using the end user’s auhtentication, then you can use something like fetch() as mentioned above or any high level HTTP client library.

If you want to make the HTTP requests from the server, for additional caching and aggregation possibilities and the possibility to use e.g. an API key that is kept secret from clients, then you can use your favourite Java HTTP client such as java.net.http.HttpClient that was introduced in Java 11 or a REST client such as Jersey Client. You can then use a regular Fusion @Endpoint to trigger the server-side fetching logic from TypeScript code.

Erik Lumme:
Hi André, from your JavaScript/TypeScript code you can use the [Fetch API]
(https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch).

Leif Åstrand:
There’s nothing special in Fusion when it comes to accessing external resources over HTTP - you can use the same approach as you would use without Fusion.

If you want to make the HTTP requests from the browser, for direct access and using the end user’s auhtentication, then you can use something like fetch() as mentioned above or any high level HTTP client library.

If you want to make the HTTP requests from the server, for additional caching and aggregation possibilities and the possibility to use e.g. an API key that is kept secret from clients, then you can use your favourite Java HTTP client such as java.net.http.HttpClient that was introduced in Java 11 or a REST client such as Jersey Client. You can then use a regular Fusion @Endpoint to trigger the server-side fetching logic from TypeScript code.

Thank you guys, I’ve thinked that the Connect has some api to make external requests.