I'm getting an error when trying to stringify a global variable in sails: TypeError: converting circular structure to JSON.
I know what the error means, but the question is, what's happening that's causing there to be a circular reference. And, why does it happen to my custom variable?
Then the next question is: how can I stringify the object the way I created it in globals.js?
In config/globals.js:
module.exports.globals = {
mystuff: {
Url: "http://localhost:8080",
APIKey: "2bb67717b99a37e92e59003f93625c9b"
}
}
In a hook initialize:
module.exports = function (sails) {
return {
initialize: function(cb) {
var str = JSON.stringify(sails.config.globals.mystuff);
}
}
}