AngularPWASeed | A starter project for a PWA | Command Line Interface library
kandi X-RAY | AngularPWASeed Summary
kandi X-RAY | AngularPWASeed Summary
A starter project for a PWA built in Angular 2+
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of AngularPWASeed
AngularPWASeed Key Features
AngularPWASeed Examples and Code Snippets
Community Discussions
Trending Discussions on AngularPWASeed
QUESTION
I have recently begun converting my Angular 7.2.0 app to an Angular universal app. The app is successfully rendering server-side, and transfers state fairly quickly on fast PCs and internet connections, but unfortunately until the hand-off, the rendered page is missing any data normally fetched from the API.
I have added the serverURL
to a provided token from the server, and while rendering server-side, all http requests are made using the fully qualified url. However, it appears that does not matter, since all http calls are cancelled before they complete! My server shows no calls to the api endpoints, and the client logs an error of {}
(which shows up as [Error]
by default).
I am using the TransferStateModule
, as well as the TransferHttpCacheModule
, but nothing has worked so far. It seems like the express-engine render just will not wait for async http calls. It affects the http calls in ngOnInit
of components, the constructor
s of services, and any in resolver
s, so I don't know how else to get the data.
For things like config data, I am injecting the necessary fields as a token, and checking that token on server-side renders, but I cannot do that for all data in the app.
Below are the relevant sections of my server and app modules
app.ts (node express server)
...ANSWER
Answered 2019-Jan-18 at 04:38Thanks to @CaerusKaru for solving this one in the @nguniversal issues page! https://github.com/angular/universal/issues/1046#issuecomment-455408250
Essentially, the problem was the interceptor
I use to append the full server path to api calls. It was using Object.assign(request, {url: fullServerUrl});
to set the new url for all http requests beginning with /
. The appropriate method is apparently request.clone({url: fullServerUrl});
and changing that one snippet caused the data to flow like a rushing stream.
Hope this helps someone else, and I will be turning the repro-repo (hard to say and type) in to boilerplate of Angular7 and Universal as a working starter point.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install AngularPWASeed
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page