Cannot Access All Object Data from Store


#1

I’m new to Ember so please forgive my ignorance. I am working on a search page where I have a route that accepts a search param and is passed to a query:

  model(param){
    return this.get('store').query("search-result", { filter: {"searchTerm": param["term"]}});
  }

When on the template when I try to load the ‘displayName’ of the result nothing appears. However when I call ‘content’ which is the other attribute of the object the content renders. Why would this be?

I am using a JSONAPI adapter with a valid (I think) JSONAPI. Here is an example incoming result:

{"data":[{"type":"search-results",
"id":"57a4a478a69a6d457a4b7bb7",
"attributes":{"content":"blah",
"displayName":"foo",
"searchTerm":"bar"},
"relationships":{},
"links":{"self":"http://localhost:8080/api/search-results/57a4a478a69a6d457a4b7bb7"}}]
}

Any direction would be great thanks!


#2

Just to follow up on this. I changed content to searchContent because I thought it would be a conflict (from what I could find online). I have also added a serializer. Now I don’t see anything :slight_smile: which is progress (I think) because I think I was overriding the content attribute with my object.

However now my objects have nothing but ids.


#3

I solved the problem by creating a serializer with the following method

 keyForAttribute: function(attr) {
        return attr;
    }

The problem was I was using camel case and Ember expected it to be dashed. So I overrode the seralizer to leave it alone since it was coming in as camel case.