From the course: Angular: Creating and Hosting a Full-Stack Site

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Create an endpoint for adding views

Create an endpoint for adding views

From the course: Angular: Creating and Hosting a Full-Stack Site

Start my 1-month free trial

Create an endpoint for adding views

- So we've seen the basics of querying our database now, and our server is able to load listings from our database and send them back to the client. The next thing we're going to add to our server is an end point for keeping track of how many times each listing has been viewed. Now, we actually, haven't built this into our front end yet. We'll get to that in a little while, but what we want at the top of each listing page is a little message that says something like this listing has been viewed 125 times, for example. And of course we'll want to increment this number every time someone visits the page. So in order to implement this functionality, what we're going to do is inside our routes folder, we're going to create a new file and we're going to call it, add view to listing.js and inside that we're going to define a route that looks something like this. We're going to import our database object from dot dot slash database.…

Contents