I'm trying to consume the following JSON response in Ember.
[
{
"url": "https://example.com",
"files": {
"config.json": {
"name": "config.json"
},
"style.css": {
"name": "style.css"
}
},
"user": null
},
{
"url": "https://newexample.com",
"files": {
"settings.json": {
"name": "settings.json"
},
"index.html": {
"name": "index.html"
}
},
"user": null
}
]
Here's my first model "snippet":
export default Model.extend({
url: attr('string'),
files: hasMany('file')
});
And then my "file" model with which I created a hasMany Relationship to:
export default Model.extend({
name: attr()
});
index.js route:
export default Ember.Route.extend({
model() {
return this.store.findAll('snippet');
}
});
I realise that this won't work since I'm not defining the first variable in "files". Though I can't figure out how one would do this since this variable is dependent on the filename.
Any help would be appreciated. Thanks.
Aucun commentaire:
Enregistrer un commentaire