I am getting the following error while trying to convert object to string using Node.js/JavaScript:
TypeError: Converting circular structure to JSON
at Object.stringify (native)
at exports.userlogin (/opt/lampp/htdocs/FGDP/route/route.js:11:19)
at Layer.handle [as handle_request] (/opt/lampp/htdocs/FGDP/node_modules/express/lib/router/layer.js:95:5)
at next (/opt/lampp/htdocs/FGDP/node_modules/express/lib/router/route.js:131:13)
at Route.dispatch (/opt/lampp/htdocs/FGDP/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/opt/lampp/htdocs/FGDP/node_modules/express/lib/router/layer.js:95:5)
at /opt/lampp/htdocs/FGDP/node_modules/express/lib/router/index.js:277:22
at Function.process_params (/opt/lampp/htdocs/FGDP/node_modules/express/lib/router/index.js:330:12)
at next (/opt/lampp/htdocs/FGDP/node_modules/express/lib/router/index.js:271:10)
I am providing my code below:
exports.userlogin=function(req,res){
var username=req.body.user_name;
var password=req.body.user_pass;
var ciphertext = CryptoJS.AES.encrypt(password, 'lexelPass');
var pass=JSON.stringify(ciphertext);
}
Here I am getting ciphertext variables datatype is object and I need it to convert into string. But here I am getting this type of error.
ciphertext? What type is it ?ciphertexthere is either aword-arrayor abyte-arrayand not an object. Do the necessary conversion to object first.object.