skip to Main Content

Mongodb – Unable to get document using document.findOne()

I tried to get a document using document.findOne() but it's value is showing undefined . Here is my code `app.post("/studentlogin",(req,res)=> { let password; console.log("login page"); bcrypt.hash(req.body.password,saltRounds,(err,hash)=> { const user= Student.findOne({srno:req.body.srno}); console.log(user.srno); if(req.body.srno==user.srno && hash==user.password) { session=req.username; session.userid=req.body.srno; res.redirect("/"); } else{…

VIEW QUESTION

AWS HTTP API Gateway + Lambda ( Node/express) 503 Service unavailable

I don't have much knowledge in AWS I have following setup, const express = require("express"); const serverless = require("serverless-http"); const app = express(); app.use(cors()); app.use((req, res, next) => { res.setHeader('Connection', 'keep-alive'); res.setHeader('Keep-Alive', 'timeout=30'); res.setHeader("Access-Control-Allow-Headers", "X-Requested-With,content-type"); res.setHeader("Access-Control-Allow-Origin", "*"); res.setHeader("Access-Control-Allow-Methods", "GET, POST,…

VIEW QUESTION

Mongodb and Gridfs file download

I'm building an application that allows the user to upload and download files. The issue i'm currently having is that I can retrieve the file from my MongoDB database and download it locally through my machine, but I can't get…

VIEW QUESTION
Back To Top
Search