HTTP/1.1 200 OK but the content is empty {}

Viewed 25

Hi I am trying to create a signup form here I am checking my node js with test.http.My response is 200 but the information for the signup I am passing is not reflected its empty. I am using Mongo.

This is my schema

const mongoose = require('mongoose')

const signUpTemplate = new mongoose.Schema({
    imageUrl:{
       type:String,
       required:true
    },
    firstName:{
        type:String,
        required: true
    },
    userName:{
        type:String,
        required:true
    },
    emailId:{
        type:String,
        required: true
    },
    password:{
        type:String,
        required: true
    },
    date:{
        type: Date,
        default: Date.now
    }
})

module.exports =  mongoose.model('click', signUpTemplate)

This is my router.js

router.post('/signup',async (req,res)=>{
    const saltedPassword = await bcrypt.genSalt(6);
    const securePassword =  await bcrypt.hash(req.body.password, saltedPassword)
    const signedUser = new signUpTemplateInstance({
        imageUrl: req.body.imageUrl,
        firstName: req.body.firstName,
        userName:req.body.userName,
        emailId: req.body.emailId,
        password: req.body.password
    })
    signedUser.save()
    .then(data => {
        res.send({message:"saved"})
        console.log(data)
        res.json(data)
    })
    .catch(err =>{
        res.json(err)
    })
})

This is my test.http:

HTTP/1.1 200 OK
X-Powered-By: Express
Access-Control-Allow-Origin: *
Content-Type: application/json; charset=utf-8
Content-Length: 2
ETag: W/"2-vyGp6PvFo4RvsFtPoIWeCReyIC8"
Date: Mon, 19 Sep 2022 11:43:17 GMT
Connection: close

{}
1 Answers

Solved it. I changed the password to my db with only alphabets in it and it worked. thank you @robertKlep.

Related