I am facing an issue with my Django API response when trying to retrieve data in my Backbone.js frontend - only part of the data is being received.
The current response structure is as follows:
{"count":27,"next":"http://127.0.0.1:8000/messages/?page=2","previous":null,"results":
[
{"url":"http://127.0.0.1:8000/messages/1/","creator":"CREATOR","content":"CONTENT","post_date":"2015-04-21T22:13:08.654152Z"},
{"url":"http://127.0.0.1:8000/messages/2/","creator":"CREATOR2","content":"CONTENT2","post_date":"2015-04-21T22:13:08.654152Z"},
...
]
}
The problem lies in the presence of a next
field in the response leading to the rest of the data. How can I efficiently handle this situation in Backbone to fetch complete server responses?
**Here's the snippet of the sync
function within my collection:
sync: function(method, model, options) {
var that = this;
var params = _.extend({
type: 'GET',
dataType: 'json',
url: that.url,
processData: false
}, options);
return $.ajax(params);
}
This function initiates a GET
request to http://127.0.0.1:8000/messages/
. However, I need guidance on how to handle subsequent requests for the data referenced by the next
parameter in the response.