-
Type: Task
-
Resolution: Won't Fix
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Environment:Ubuntu 18.04 bionic
-
Empty show more show less
hi! i encountered this error and i have no idea how to solve this: TypeError: Converting circular structure to JSON
// this is my model const mongoose = require("mongoose"); const Schema = mongoose.Schema; const User = new Schema({ firstname: { type: String, required: true }, lastname: { type: String, required: true }, organisation: { type: String, required: true }, address: { type: String, required: true }, email: { type: String, unique: true, required: true, match: [ /[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?/, "invalid email" ] }, status: { type: Boolean, default: false }, password: { type: String, required: true }, accountType: { type: String, default: 'regular', required: true }, package: { type: String, default: 'classic', required: true } }); module.exports = mongoose.model("User", User); User.create({ firstname: req.body.firstname, lastname: req.body.lastname, organisation: req.body.organisation, address: req.body.address, email: req.body.email, password: hash, accountType: req.body.accountType, package: req.body.package }) .then(data => { // stuffs here gets executed and logged to console /* except here res .status(201) .json({ message: "Success! Find verification link in E-mail", encData: encodedData, details: doc }); */ }) .catch(err => { // this gets executed too res .status(500) .json({ message: err + ": Couldn't create Account" }); })
At the end the document gets added. i really do not understand whats happening. It happens with both postman and angular7 on ubuntu 18.04 lts
Thanks