@iaskquestions wrote:
Hi All
I am using Ember 2.x with Ember Data 2.x with the RESTApdapter.
I am struggling to make sure that my POST requests are sending the right JSON data. For example, I do something like:
43 let posObj = this.get('store').createRecord('pos', { 44 name: posname 45 }); 46 posObj.save(); 48 let uObj = this.get('store').createRecord('user', { 49 username: user, 50 }); 52 uObj.get('poss').pushObject(posObj); 53 uObj.save();
I am expecting this to save the
pos
object and then create a newuser
object with ahasMany
reference to thepos
object.This does not throw an exception. However, when a request is finally made to my server at the
/api/users
endpoint, it only shows:
{u'user': {u'username': u'fsdaf', u'pos': [None]}}
Notice that
pos
shows up asNone
in the end result. Models look like:
User
:export default Model.extend({ username: attr(), pos: hasMany('pos') });
Pos
:export default Model.extend({ name: attr(), mos: hasMany('mos'), users: hasMany('user') });
Any help or suggestions would be appreciated!
Posts: 1
Participants: 1