Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4828

Convert JSON Object to Internal Model

$
0
0

@mapeveri wrote:

Hi everyone!. I have this problem: From websocket i received one object json and need add this object to model.

let objWs = {
                "data": {
                    "id": 1,
                    "type": "notifications",
                    "attributes": {
                        "topic": obj.topic,
                        "comment": obj.comment
                    },
                    "relationships": {},
                    "meta": {}
                }
            };

this.get('model.notifications').unshiftObject(objWs);

But return this message: “Uncaught TypeError: internalModel.getRecord is not a function”

Also try this:

this.get('model.notifications').unshiftObject(this.get('store').normalize("notification", objWs));

Return this message: “Uncaught TypeError: Cannot read property ‘replace’ of undefined”

What is the correct way to transform a json object to an internal model?. I need this record to be automatically added to a #each that I have in the template.

Thanks!!

Posts: 9

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4828

Trending Articles