I'm just trying to prerender an component with Angular Universal which fetches data with httpClient from the /static
folder within the app itself.
- How do I use httpClient correctly in Angular Universal?
- Is it possible to access static assets from within the project and fetch them with httpClient while prerendering?
I guess the file is not accessible since the application is not running on any server while prerendering. The get path is referred relativ. Fetching the file later on remote server works, however the "remoteserver" is not available during prerendering or? How can this be made working?
I do get an Error [ERROR] which is caused by the httpClient.get()
. Catching the error the error message is empty.
basically I do have a service
doReqeust() = {
return this.httpClient.get("./static/get.json")
}
and in the compoonent
onInit() {
this.data = this.myService.doRequest();
}
and the view than it is bound through async pipe
{{ data.response.title | async }}
with static being a static folder within the project.