I have utilized Babel to create an ES6 class and now I am looking for a way to map JSON data from a server to this ES6 class.
Is there a commonly used method to accomplish this task?
User.js
export default class User {
constructor() {
this.firstName;
this.lastName;
this.sex;
}
}
app.js
import User from "./classes/User";
var data = JSON.parse(req.responseText);
console.log(data.firstname); //Bob
//should I set the data one by one?