@arasbm alternatively, using the new fetch API in latest browsers:
const baseRoute = '/api/users';
fetch(baseRoute)
.then(res => res.json())
.then(data => {
const pageCount = data.pagination.pageCount;
return Promise.all(
// incremental array of pageCount elements
Array.from({ length: pageCount }, (x, i) => i + 1)
// map to an array of promises to page results
.map(page =>
// fetch page
fetch(`${baseRoute}?page=${page}`)
.then(res => res.json())
// get user joindates
.then(data =>
data.users.map(user => ({
joindate: user.joindate,
username: user.username,
}))
)
)
);
})
// flatten pages
.then(pages => [].concat(...pages))
// now you have an array of usernames + joindates
// maybe make a CSV?
.then(users => {
const csv = users
.map(user => `${user.username}, ${new Date(user.joindate).toISOString()}`)
.join('\n');
console.log(csv);
});
Which would output a CSV where column A and B are the username and joindate (in ISO format) respectively, with each user on a new line.
BTW, that code works on this site, if you open the JS console and paste it in, then wait for the result, it eventually writes the full list to console.
You can then import it into Excel of it's a one time use thing, or set up a more complicated script.