Converting circular structure to JSON nodeJs code example

Example 1: Converting circular structure to JSON

//The error means that the object you pass in the request has a circular reference, something like:

var a = {};
a.b = a;

Example 2: javascript circular evaluation

Game.prototype.restart = function () {
  this.clearLocalStorage();
  this.timer = setTimeout(this.reset.bind(this), 0);  // bind to 'this'
};

Game.prototype.reset = function(){
    this.clearBoard();    // ahhh, back in the context of the right 'this'!
};

Example 3: res : [ Circular ] nodejs

http.get(url, function(err, response) {
  if (err) console.log(err)

  var data = ''
  response.setEncoding('utf8')
  response.on('data', function(d) {
    data += d
  })
  response.on('end', function(d) {
    res.send(data)
  })
})