1

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 (i.e., 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!

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you. I learned about the Api's and did it!
@TanYa Congratz :D If you want to learn more I suggest this course: fullstackopen.com/en It's free, open-source and really good

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.