Loading...
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.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Http request external endpoint

André Silva
10 months ago Apr 16, 2021 10:52pm
Erik Lumme
10 months ago Apr 19, 2021 6:21am
Leif Åstrand
10 months ago Apr 19, 2021 6:25am

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.

Last updated on Apr, 19th 2021
André Silva
10 months ago Apr 19, 2021 2:23pm