Could not get any raw data while converting using .models canjs

515 Views Asked by At

With the new CanJS update, my Models stopped working and I dont know why.

This is what my code looks like:

    Module = can.Model.extend({
           findAll: 'GET ' + window.rootPath+'api/module'
    }, {});

    FormModule = can.Control.extend({}, {
    init: function (element, options) {
        var self = this;

        Module.findAll({}, function (data) {
            self.element.html(can.view('viewModulesResult', data));               
        },            
        function (data) {
            console.log(data);               
        });                 
    }        
    });

Since I'm starting with javascript, I'm not very good at it, so I have no idea of whats wrong. When I pass the mouse over console.log(data) in the Console, this message appears: "Could not get any raw data while converting using .models" Does anyone knows whats wrong?

1

There are 1 best solutions below

0
On

The return isn't an array. can.Model.parseModels should be used to convert the ajax responses into a data format useful to can.Model.models. Reference: http://canjs.com/docs/can.Model.parseModels.html