contentful.js icon indicating copy to clipboard operation
contentful.js copied to clipboard

Cannot Render Contentful content by using Angular Universal (SSR)

Open shahbazshoukat opened this issue 4 years ago • 4 comments

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

shahbazshoukat avatar Apr 07 '20 14:04 shahbazshoukat

Same issue

fpl1976 avatar May 07 '20 15:05 fpl1976

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.

shahbaz-shoukat avatar May 07 '20 18:05 shahbaz-shoukat

Yeah, makes sense. I'm going to try this solution. Thx!

fpl1976 avatar May 08 '20 14:05 fpl1976

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.

randysimplist avatar Jun 29 '20 23:06 randysimplist

A working solution seems to be provided. Closing this for now.

marcolink avatar Jun 07 '23 06:06 marcolink