Category : express

I am trying to pass a simple json to the server using POST. How do I retrieve the value on the server side? In this case, the value is a stringified JSON [{"key": "value"}], which accounts for the [0] on the server. index.html <form id="form" method="POST" style="background-color:#92a8d1" style="font-size: 18px; font-family:verdana,arial,tahoma,serif;"> <label for="data">Demonstrations:</label><br> <ul> <li><input type="button" ..

Read more

//jshint esversion:6 const express = require("express"); const bodyParser = require("body-parser"); const mongoose = require("mongoose"); const _ = require("lodash"); const app = express(); app.set(‘view engine’, ‘ejs’); app.use(bodyParser.urlencoded({ extended: true })); app.use(express.static("public")); mongoose.connect(‘mongodb+srv://admin-sonu:[email protected]/todolistDB’, { useNewUrlParser: true, useUnifiedTopology: true }); const workItems = []; const itemsSchema = new mongoose.Schema({ name: String }); const Item = mongoose.model("Item", itemsSchema); const ..

Read more