title: NodeJS: return getter property of class instance in res.json
body: <p>In my code below, </p>
  
  <ul>
  <li>I'm calling the static "findAllPeople" method in my Person class. This method returns a set of Person objects.</li>
  <li>The Person class also has a getter for fullName.</li>
  </ul>
  
  <p><strong>Problem:</strong>
  The <code>res.json(Array.from(people))</code>returns an array of the Person objects, but without the fullName property.
  When I debug <code>Array.from(people)</code>in VS Code it correctly returns the array of Person objects WITH the fullName property. But when I evaluate <code>JSON.stringify(Array.from(people))</code>, I get a String without the getter property.</p>
  
  <p>I've already tried using <code>[...people]</code> instead of <code>Array.from(people)</code>. But same result.
  So it's the stringify action which causes this problem (I assume ...).</p>
  
  <p><strong>How can I create a response which returns the array WITH the fullName property (based on the fullName getter)?</strong></p>
  
  <p><strong><em>controller.js</em></strong></p>
  
  <pre><code>const Person = require('./Person');
  
  exports.getAll = function(req, res, next) {
      Person.findAllPeople()
          .then((people) =&gt; {
              res.json(Array.from(people));
          })
          .catch((err) =&gt; {return next(err);});
  }
  </code></pre>
  
  <p><strong><em>Person.js</em></strong></p>
  
  <pre><code>class Person {
      constructor(personId, first, last, email, birthday) {
          this._id = personId ? personId : undefined;
          this.firstName = first ? first : undefined;
          this.lastName = last ? last : undefined;
          this.email = email ? email : undefined;
          this.birthday = birthday ? new Date(birthday) : undefined;
          this.relations = new Map();
      }
      get fullName() {
          return `${this.firstName} ${this.lastName}`;
      }
      static findAllPeople() {
          return personRepository.getAll("ONLY_NAMES")
              .then((people) =&gt; {
                  people.forEach((person) =&gt; {
                      if (person.relations.size === 0) {
                          person.relations = undefined;
                      }
                  })
                  return people;
              })
              .catch(console.error);
      }
  }
  module.exports = Person;
  </code></pre>