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

Create an endpoint to edit listings

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

Start my 1-month free trial

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…

Contents