I try use yammer SDK https://c64.assets-yammer.com/assets/platform_js_sdk.js to make async call like the code below.
The javascript SDK doc is here https://developer.yammer.com/docs/js-sdk
What the code currently does is to return an Array of 50 users' profile. The total number of users is unpredictable.
What I want:
When the returned array.length in previous call is equal to 50, i.e. there could be more users in following page, make another call with index++ to the same API URL.
This is repeated until there is no more users to be fetched.
But how to make it?
yam.connect.loginButton('#yammer-login', function (resp) { console.log(resp.authResponse); var index = 1; if (resp.authResponse) { //trigger data process yam.platform.request({ url: "users.json",
method: "GET", data: {
"page": index }, success: function (user) { console.log("The request was successful."); console.log(user.length); }, error: function (user) { console.log("There was an error with the request."); } }); }else{ console.log("error to get access_token"); } });