From the course: Angular: Creating and Hosting a Full-Stack Site
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Create an endpoint for adding views
From the course: Angular: Creating and Hosting a Full-Stack Site
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.…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Why MySQL?2m 16s
-
(Locked)
Install MySQL and MySQL Workbench3m 19s
-
(Locked)
Set up a MySQL database5m 32s
-
(Locked)
Connect to a MySQL database from Node6m 44s
-
(Locked)
Rewrite the listings endpoints8m 20s
-
(Locked)
Create an endpoint for adding views5m 29s
-
(Locked)
Create an endpoint to get a user listing3m 13s
-
(Locked)
Create an endpoint to create listings6m 13s
-
(Locked)
Create an endpoint to edit listings4m 34s
-
(Locked)
Create an endpoint to delete listings2m 33s
-
-
-
-
-