Domanda

Here's a fetch operation I've written in a view:

this.collection.fetch ({
            data:{
                values: 100,
                type: "normal"
            },
            success:(collection, response) => {
                _.each(collection.models, (model) => {
                    Log.show(model.get("question"));
                })
            },
            error: (err) => {
                Log.error("couldn't receive data");
            }
        });

My Webstorm throws an error on fetch({}) that says Supplied Parameters are incorrect

I'm not able to find any other api specification for the fetch call. The code is in and the typescript definition for backbone I'm using is here:

https://github.com/borisyankov/DefinitelyTyped/blob/master/backbone/backbone.d.ts

UPDATE==

The result I see in the log is this:

Triple
Triple
Triple
Triple
Triple

Here "triple" is the value of the "question" attribute in the last model added to the collection. There are 5 models in the collection (in the persistent) database and if there were 6 it would display "Triple" 6 times. There is some problem in the API call I made to get the value of the question object

I'm probably not calling the function right. I need to know whats the appropriate call for getting the value of an attribute from the model. Or this could be a problem actually retrieving the values from the server.

I've tried the following to actually get the right value in the log:

Log.show(model.toJSON().question);
Log.show(model.toString());
Log.show(model.question);
È stato utile?

Soluzione

The success callback should look like this:

success:function(collection, response){}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top