I have created a simple signup and login using node js and mongoDb. I can successfully do signup and login and now I want to add some more data to the user model after logging in from the secret page. How can I do that?
This is my user model and I want to add some text to user.text
field after loggin in:
var mongoose = require("mongoose");
var UserSchema = mongoose.Schema({
username: String,
password: String,
text:String
});
module.exports = mongoose.model("User", UserSchema);
This is my view page (ie, the secret page)
<h1>Hi, <%= user.username %></h1>
<form action="/birthday" method="post">
<input type="text" name="text">
<button type="submit">Update database</button>
</form>
The text should be shown here after updating .
Thanks!
You need to make an API on the node process to send the data to. I suggest you take a look at stuff like Express.js and google about REST API:s.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.