K
K
Kirill Gorlov2015-06-19 10:08:50
backbone.js
Kirill Gorlov, 2015-06-19 10:08:50

What to do if the server gives a non-standard data array for Backbone?

I use a bunch of Kohana + Backbone
I make a request with a collection to the address:
/kohana/v1/welcome.json
In response, I receive data of the format:

{
    "action": {
        "restexample": [
            {
                "name": "Kirill",
                "age": 25,
                "job": "web-developer"
            },
            {
                "name": "Andrey",
                "age": 12,
                "job": "web-developer"
            },
            {
                "name": "Семен",
                "age": 43,
                "job": "web-developer"
            },
            {
                "name": "Куршавеёйль",
                "age": 23,
                "job": "web-developer"
            }
        ]
    }
}

How can I tell Backbone that my data is not coming from the way he is used to receiving it by default?
Where is the right place to do it? In the model? Or in the Collection?
You cannot change the answer from Kohana.
The module has such a structure to pass service parameters and headers.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2015-06-19
@Chetson

To do this, you need to override the parse method in the collection .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question