From the course: Building Vue and Node Apps with Authentication

Unlock the full course today

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

Creating a Node register service

Creating a Node register service

From the course: Building Vue and Node Apps with Authentication

Start my 1-month free trial

Creating a Node register service

we'll create a backend register endpoint. Let's begin by copying our app.post /messages endpoint between line 21 to line 27 and pasting it below. We'll rename it to /register. And then we'll change the variable on line 32, registerData. Let's console.log the registerData just for now, and actually I'll go to our old app.post /messages and get rid of the two console.logs Let's save that and give it a try. I'll just pass in some placeholder data for now. And you can see now, instead of a 404, we're getting a 200 and we're getting our registerData passed back to us so we know it's working. Now let's create an array on our backend where we can save our users. So I'll scroll through the top, and I'll make an array, and initialize it with an empty array. Now let's go back down, and let's push the registerData into our users array. And then I'll change our console.log on line 30 to just display the users array to make sure it's being added. Let's give that another try, I'll hit REGISTER, and…

Contents