Angular Universal view page source not showing API data

依然范特西╮ 提交于 2020-03-21 06:38:31

问题


I have an Angular 6 application which is working fine on both local development environment as well as on production machine. The data is fed by an API to the application. Application is showing the data just fine by using observable, resolve and promise techniques.

I have made a Universal version of the application (Server Side Rendering or SSR) for SEO purposes which also works fine.

I just have one issue;

When I post my application to production, it displays the contents that are coming from the API just fine, however when I view the "Page Source" on the browser, I'm not able to see the contents that were rendered on the page.

Please note that I have the data coming through "Route Resolve" and it is not the case of async/await issue.

Thank you in advance.


回答1:


Sorry for a late response since this was an issue from last year and because I figured out what the issue was, I never looked at this issue again. I try to explain here as much as I can.

The data was coming through an AWS API Gateway which was connected to the app via credentials and keys. The data was showing just fine on the page but not when I was looking at the page source. I thought that there is a problem with the API, but after spending days figuring out, I found out that the data is just getting received fine from the API.

I just used "inspect" on the page on Chrome (right click and inspect) and looked at "console" tab and realized a bunch of methods in the app throwing errors. When I investigated the errors I found out there are bunch of data type mismatches associated with the data types I was getting from the API.

As a result, the issue was with the app not the API. A silly issue like this took me almost a week to fix. I hope this would shed some light for you.



来源:https://stackoverflow.com/questions/51972936/angular-universal-view-page-source-not-showing-api-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!