Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Http request external endpoint
How can I send an external http request from vaadin fusion frontend?
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.
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.