AnsweredAssumed Answered

Can return enrollments- how to handle pagination?

Question asked by Michael Salmons on Dec 8, 2018
Latest reply on Dec 13, 2018 by Tony Harris

This Node script is working well to return enrollments- but I am struggling with pagination.


const request = require('request');

let url = '[]=StudentEnrollment&state[]=active&access_token=blahblahblahblah&page=13&per_page=100&include[]=login_id rel="next"';

request(url, function (err, response, body) {
console.log('error:', error);
} else {
let results = JSON.parse(body)

for (var i in results) {



the only way i know how to cycle through the pages is manually with page number in the URL, example: page=2, page=3, etc.


How can this be automated?


How can I design the script so it knows it's at the end? I assume an if-then structure that checks the state of rel. As long as it's "next," it keeps going, but what about when it's "last?"


Any help would be most appreciated. It's a rather urgent need. Thank you.