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 to edit listings
From the course: Angular: Creating and Hosting a Full-Stack Site
Create an endpoint to edit listings
- [Narrator] Okay, so we're getting to the end of our Server Routes. The next one we're going to create now, is a route that will allow users to edit their listings. So let's get right down to business We're going to call this one update listing dot js. And then we're going to define our route. So we'll say import db from dot data slash database. And then export const we're going to call it update listing route. And this will be a POST route so we'll say method POST. The path for this route is going to be slash api slash listings slash id in curly braces. And then we have the handler which like all of our other ones is going to be async. So what we're going to do first is we're going to start off by getting the id from our URL parameters. So we'll say const id equals req dot params and then we're going to get the updated name, description and price values from the request payload. So we're going to say name…
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
-
-
-
-
-