contentful.js
contentful.js copied to clipboard
Cannot Render Contentful content by using Angular Universal (SSR)
Expected Behavior
Dynamic Content from Contentful should be rendered in Browser's page source.
Actual Behavior
Content is not rendering using Angular Universal.
Context
I am working on an angular app with Contentful CMS which needs to be SSR. I have followed all the steps mentioned here Angular Universal. But its just rendering the static content, not the dynamic content from Contentful. I have also tried TransferState API but its not working with Contentful. Have also seen #289 and tried ngx-axios-adapter but getting 404 response.
- Language Version: Angular 7.3.9 Node 8.12.0
- Package Manager Version: 6.13.4
- Operating System: macOS 10.14.5
- Package Version:
- Which API are you using?: Both Delivery and Management
Same issue
Same issue
@fpl1976 I have resolved the issue by using Contentful API instead its SDK. Use its API with HttpClient.
API Reference: https://www.contentful.com/developers/docs/references/content-delivery-api/
NOTE: Use full API url in HttpClient without any proxy.
Yeah, makes sense. I'm going to try this solution. Thx!
The real issue here is that Angular doesn't wait for the API to return before rendering the page. By using HttpClient you are forcing Angular's SSR process to wait for the call to complete before rendering is completed.
You can work around this issue by specifying an adapter (such as Axios) in createClient
.
A working solution seems to be provided. Closing this for now.