dimanche 30 septembre 2018

Error message in nodejs: backend returned code 400, body was null

I am developing a web application using MEAN Stack with Angular 6. I am struggling with the following error for days. I have an input field which shows a color picker. It allows us to select the color. This is my color schema.

var mongoose = require('mongoose');

var rdaColorSchema = new mongoose.Schema({  
  colorMovementBox: {
      type : String,
  },
});
module.exports = mongoose.model('rdaColor', rdaColorSchema);

This is my back end.

router.post('/save', (req, res)=>{
    var rdaColorVal = new rdaColor(
        {
            colorMovementBox: req.body.colorMovementBox,
        }
    );

rdaColorVal.save((err,doc)=> {
    if(!err){

        res.send(doc);}
        else{
            console.log(err);
        }
        });
});

When I debug the project I can see color values in the front end(I have used an ngx-color picker to select colors). But the back- end gives following errors. error

I searched a lot about this error. But nothing worked.




Aucun commentaire:

Enregistrer un commentaire