From the course: React: Software Architecture
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Data loading with SSR
From the course: React: Software Architecture
Data loading with SSR
- [Instructor] So in order to have our server be the one that loads the data for our application, instead of our front end, there's a few changes we're going to need to make. The first thing we're going to need to do, is go down to where we actually render our app and we're going to need to load the data here. Now, loading the data in our case is going to be fairly simple. Since we're on the server, we have access to the data that the server contains, right? And if this were in a database, our server would be able to communicate directly with the database instead of having to make its own API request. So here's what this is going to look like, inside where we say fs.read file, and insert the rendered app into the HTML, what we're going to do is load the data for the articles. Again, just to make this a little more realistic, I'm going to say const loaded articles equals articles. This would normally be where we'd connect…