简体   繁体   中英

Fetch data when building for production, Angular

I'm building an Angular application that needs to get some data from a server, the data is not changing very often so I don't want to make a request every time someone loads the application, I would rather make a call every time I build the app and have it as part of the bundle.

So my question is: is there a way to fetch data from a server when building, and using it in the application? (and for serving in dev mode it should maybe fetch on each build)

I think you are looking for Angular Universal prerendering. It's quite complex to describe in one short answer, but you can start exploring for instance from this tutorial: 💥 Angular Universal: Pre-Rendering with renderModuleFactory

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM