Answers for "TypeError: Converting circular structure to JSON"

1

TypeError: Converting circular structure to JSON

I run into this issue, because i was sending as response the full response of another api call instead of just the data i needed.
Posted by: Guest on October-29-2021
0

json stringify close circle

const getCircularReplacer = () => {
  const seen = new WeakSet();
  return (key, value) => {
    if (typeof value === "object" && value !== null) {
      if (seen.has(value)) {
        return;
      }
      seen.add(value);
    }
    return value;
  };
};

JSON.stringify(circularReference, getCircularReplacer());
Posted by: Guest on November-09-2020
3

UnhandledPromiseRejectionWarning: TypeError: Converting circular structure to JSON

I also ran into this issue. It was because I forgot to await for a promise.
Posted by: Guest on October-17-2020
0

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'!
};
Posted by: Guest on March-26-2020

Code answers related to "TypeError: Converting circular structure to JSON"

Code answers related to "Javascript"

Browse Popular Code Answers by Language