Jump to content

Search the Community

Showing results for tags 'asynchronous'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Support
    • Support
    • Common Questions
  • General
    • The Frog Academy
    • General chat
    • Showcase
    • Webinars
  • Technical Forums (How do I...?)
    • Learn / Play / Progress
    • Coding

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


School

Found 1 result

  1. @Chris.Smith @Graham Quince any advice please on the following? I am trying to combine information from two frog api calls. Firstly calling getMembers to return basic information about every student in a particular group. Secondly looping through each student and calling getDataInCategory to return extra information. I am assuming there is no extra parameter I can add to the first call to get the extended information without making the second call! Regardless I quite like to know how you would go about beating the async issues anyway. The issue is that the first call does not wait for the second calls to complete. Frog.Model.api('groups.getMembers',{ignore_profiles: true, uuid: my_group_uuid}).done(function(thisResponse) { $.each(thisResponse.data, function(i, member) { //loop through each member of the group //build object as we go var thismember = {uuid: member.uuid, name: member.displayname, gender: member.gender, thumb: member.thumbnail, data:[]}; Frog.Model.api('users.getDataInCategory',{user_uuid: member.uuid,uuid: student_flags_uuid}).done(function(thatResponse) { $.each(thatResponse.data.fields, function(x, data) { //loop through each field of extra data and add the data to the data array in the thismember object var key = data.label; MyContext[key] = data.value; }); thismember.data.push(MyContext); //this happens after MyGroup.push(thismember) }); //the code below doesnt wait for the inner api call MyGroup.push(thismember); //this line always has 'data' empty. }); }); I've read about closures, async=false and promises. I don't understand the first and last, and async=false seems to be really bad practise, So what's the recommended approach here? How can i get an object out of the end of this which contains basic and extended information for each of the students in the group? Thanks for your continued support P
×
×
  • Create New...