I have hardcoded classes to represent models in my Aurelia application. Here's a model 'PostEdit':
var _postID = Symbol();
var _title = Symbol();
var _text = Symbol();
export class PostEdit {
constructor(postEdit) {
this[_postID] = postEdit.postID;
this.title = postEdit.title;
this.text= postEdit.text;
}
get postID() { return this[_postID]; }
get title() { return this[_title]; }
set title(val) { this[_title] = val; }
get text() { return this[_text]; }
set text(val) { this[_text] = val; }
}
After the object is manipulated, I need to PUT
and POST
it back to the server. But it looks like Aurelia
's HttpClient
is sending an empty JSON
string ({}
). Looking into it, it seems that Symbols
are ignored when converting an ES6 class to JSON
.
How can I go about getting all my properties into a JSON
string to submit back to the server?