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

Retrieve raw data from backend

$
0
0

@Noone wrote:

Hello,

I’m developing an app where I’m retrieving data from my REST api. All my endpoints send models. Except one, that can’t be retrieved as a model. It’s a raw array where the keys are dates and the values are an amount. This raw data is used to display a graph on the front.

Here is an aspect of the endpoint : entities/{id}/stats/

stats: [{
    id: 0,
    comments: [
        2017-02-02: 165,
        2017-02-03: 235,
        2017-02-04: 145,
        ...
    ],
    visits: [
        2017-02-02: 1040,
        2017-02-03: 2050,
        2017-02-04: 1102,
        ...
    ],
    ...
}]

Now the problem is that ember force me to use a model to retrieve it. I managed to put the top level in a model Stat, with attributes comments, visits, etc… The model is being enrich by ember but now I would like to get the raw data inside of these attributes and ember doesn’t allow to do so. It’s expecting a string, number, model etc… but not an array or javascript object. I cannot create a model because the attributes would be random dates.

How can you pass easily to a template such a structure ?

Is there a way to do so without using models ?

Thanks,

Matthieu the Lambert

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4829

Trending Articles