0
votes

I'm developing a web application with Aurelia. I had a problem with Aurelia and Whatwg-fetch.

The API's relative url is api/post/load/{id}. When I use the fetch client to call this API, I think it gets the current url to call (http://localhost:9000/detail/api/post/load/{id}). I don't know why it happens. Sometime it calls the API's url correctly, other times it does not.

1

1 Answers

0
votes

The url at which you access your app is http://localhost:9000/details. Since you didn't include a hashmark (#) in it, I assume the details part is not added by Aurelia, which leads me to believe that you access the app itself at /details.

If that is the case, the problem is that by not prefixing your API's url with a slash (/), the resulting url will be base url+api url, that is, localhost:9000/details + api/post/load/id. The slash between details and api is added on your behalf while constucting the final absolute url. In this case, all you need to do is to prefix the api url with a slash, like so: /api/post/load/{id}.