Ember Data Newbie - Very lost

Hello,

I’m brand new to emberJS, and I’ve gotten my service to load the data from my API, but when I try to access the properties on the UserModel, everything returns undefined

Here is the Data being loaded from my API

This is really really really holding me up from starting because I can’t for the life of me figure out why the data isn’t being mapped properly…

Can anyone please point me in the right direction. Thank you

Here is my UserModel with the properties on it that map to my JSON

1 Like

Ok, If anybody has run into this issue here is how I got it solved thanks to runspired on the EmberJS discord. Join if your lost

My Data looked like { data: { type: ‘user’, id: ‘1’, firstName: ‘Victor’, lastName: ‘McKenzie’ } }

When it should have looked like this { data: { type: ‘user’, id: ‘1’, attributes: { firstName: ‘Victor’, lastName: ‘McKenzie’ } } }

Explanation “historically: EmberData did not have a pluggable cache, so the cache format was rigid and only one format worked with it (JSON:API) today, we have a pluggable cache, so the cache format is opaque, it just needs to match your cache implementation but… realistically only Open Source cache implementation currently is our JSON:API one”

2 Likes

Hey man, checkout ember adapter, if you want to see data for that endpoint create adapters/user.js

You have built in mehods there to check your payload and normalize it to get correct format