Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

mongoose express js post

const express = require("express");
const route = express.Router();
const mongoose = require("mongoose");
const Schema = mongoose.Schema;

const noteSchema = new Schema({
	note: {
		type: String,
		required: true
	},

});
const noteModels = mongoose.model("note", noteSchema);

route.post("/", async (req, res) => {
    const note = new noteModels({
      note: req.body.note,
    });

    const saveNote = await note.save();
    res.json(saveNote);
  })
 
module.exports = route;
 
PREVIOUS NEXT
Tagged: #mongoose #express #js #post
ADD COMMENT
Topic
Name
7+1 =