Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9145875
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:37:18+00:00 2026-06-17T10:37:18+00:00

For the reading a table script shown below, I am trying to run the

  • 0

For the reading a table script shown below, I am trying to run the query in the parameter and for each result trying to append a value from a different table to the result. But due to asynchronous nature of azure, request.respond() is always called before getInvites. Which means that the results are never appended with invites.

function read(query, user, request) {

    request.execute({
        success: function (results) {
            for (var i = 0; i < results.length; i++) {
                getInvites(results[i].id, function (invites) {
                    console.log("Assigning results.invites"); //runs second
                    results[i].invites = invites;
                });
            }
            console.log("Request Responding"); //runs first
            request.respond();
        }
    });

}

function getInvites(id, cb) {
    var InvitesTable = tables.getTable("Invites").where({
        "PlanID": id
    }).select("UserID", "Attending");
    InvitesTable.read({
        success: function (results) {
            if (cb) cb(results);
        }
    });
}

This is a followup question from this as I am unable to use external libraries in Azure. So how can I workaround the problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:37:19+00:00Added an answer on June 17, 2026 at 10:37 am

    The asynchronous nature of the operations makes that a little challenging. What you need to do is to only call request.respond() once all the operations are done. I really miss the await keyword which I’m so fond from C#, but I’ve used an “asynchronous for loop” before, and it’s worked quite well. Your code would look something like the one shown below:

    function read(query, user, request) {
        request.execute({
            success: function (results) {
                var index = 0;
                var executeStep = function() {
                    if (index === results.length) {
                        // all invites have been retrieved
                        console.log("Request Responding");
                        request.respond();
                    } else {
                        getInvites(results[index].id, function(invites) {
                            console.log('Assigning results.invites');
                            results[i].invites = invites;
                            index++;
                            executeStep();
                        });
                    }
                }
    
                executeStep();
            }
        });
    }
    
    function getInvites(id, cb) {
        var InvitesTable = tables.getTable("Invites").where({
            "PlanID": id
        }).select("UserID", "Attending");
        InvitesTable.read({
            success: function (results) {
                if (cb) cb(results);
            }
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a recursive function reading a table of contents of documents from a
I am reading data from a table in an SQLite3 database into a ListView
I am in the Console environment busy reading all the rows from a table
Considering that TEST_SCRIPT is a CLOB why when I run this simple query from
I have a script which is reading values from an excel sheet and inserting
I have a php script which is responsible for reading some request parameters from
I am reading and trying to understand a Jquery template example. <script id=movieTemplate type=text/x-jquery-tmpl>
I am hoping someone can assist me in getting the JDBC script Reading from
I'm reading about sqlalchemy and I saw following code: employees_table = Table('employees', metadata, Column('employee_id',
Reading through the Wikipedia article on First-Class functions, there is a nice table of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.