Ajax Count all hydra:totalItems

434 views Asked by At

I have to make an ajax that counts the month of a submitted ticket, example, Jan:4 tickets, Feb:12 tickets, etc. Here is my code:

function createdAtChart(callback, createAt) {
    $.ajax({
        url: '/api',
        type: 'POST',
        data: {
            module: 'helpdesk/tickets',
            method: 'get',
            // params: [{'createdAt':createAt}]
            params: [
                {
                    'createdAt' : {
                        'before': createAt
                    }
                }
            ]
        },
        success: function (data, textStatus, jqXHR) {
            var data = JSON.parse(data);
            var total = data['hydra:totalItems'];
            console.log(total); //output 68
                var d = moment(data.createdAt).month();// The output is 8
                //8 means September
                createAt = d;
                        console.log('total = ', total); // output = 68
                if (callback) callback(d, total)
        }
    });
}

The problem is, I don't know how to get it from API. I access the ['hydra:member'], but only returns 18 data object, its because the paging. jsonld Please enlighten me. Any help would be appreciated.

EDITED Hydra view Here are the expanded hydra:view

0

There are 0 answers