#How to use Angular HttpClient inside Tauri?

1 messages · Page 1 of 1 (latest)

spare matrix
#

I have an Angular app that uses HttpClient for various requests. Now they work for the most part, but when I make a request to /api/dashboards something weird happens:

I get the correct result, which is then displayed on the frontend. In addition to that, I also get the terminal output "Assert `dashboards` not found; fallback to index.html"

Is there something I have to configure to make the default HttpClient work or why is Tauri still checking the Assets even though it should be clear that I don't reference the assets?

cursive surge
#

are you getting the terminal output on angular or tauri?

wdym Tauri is checking the assets? can you give us pastebin link to your request function and endpoint function?

spare matrix
#

I can next week, when I am again in the office.

I am getting the output while running the debug appimage binary, so on the tauri side

#

the request is a simple GET that returns a list of objects

#

I just guess that Tauri is checking the Assets, since it is giving me the same output as when I want to access a static file that is not available

cursive surge
#

so, from what I can gather… you’re attempting to fetch api/dashboards endpoint WITH Angular… FROM tauri.

Tauri is giving you an error, saying it cannot find the dashboards asset. Because, you have no api/dashboards.html

Tauri is the desktop CLIENT. You should not be using Tauri as your backend… hence, you shouldn’t be serving API requests from Tauri.

spare matrix
cursive surge
#

um, i don’t think that particuarly helps you either.

is your backend in angular?

you’re trying to use clients as REST APIs.

angular and tauri are both clients

#

you cant just make tauri’s HTTP client start communicating with another HTTPClient, you need to look into a REST API or server backend of some sort

spare matrix
#

But I don't get why Tauri seems to interfere with these requests to the backend

modern thicket
#

because if you request something like api/dashboard tauri thinks you're requesting something from the frontend files (the content of the distDir, which is what it calls an Asset here) so it tries to resolve that and fails.

cursive surge
#

Or, use any HTTPclient crate you want, reqwest etc.

spare matrix
#

so tauri shouldn't check the assest afaik

modern thicket
#

like it requests it against the current host first or something

spare matrix
#

Hmm, I will have to check once I am back in the office