Full-Stack Web Development with Vue.js and Node

(singke) #1
Building Authentication with passport.js Chapter 6

name,
email,
password,
});
User.createUser(newUser, (error, user) => {
if (error) { console.log(error); }
res.send({ user });
});
});
};

In the preceding code, we have added an endpoint, that makes a POST request to
the http://localhost:8081/users/register URL, takes the name, email, and


password of the user, and saves them to our database. In the response, it returns the user


that was just created. It's quite simple.


Now, let's test this endpoint in Postman. You should be able to see the user returned in the
response:

Free download pdf