Best Approach to call share point API within a for loop of data using javascript

Mahesh C M 156 Reputation points
2021-04-28T11:15:20.94+00:00

I am working in a SharePoint hosted app which is completely developed in JavaScript and angular js. I want to get the data from multiple sharepoint list those are have relation,from SP list we can't able to join the list and get the data. I am trying the get the details from a SP list with a data id got from another api call with in a loop of data. The loop doesn't stay still the api call respond. what is the best approachs to hold the for loop till we have got the responses from API call.

Please anyone help me on this.

Microsoft 365 and Office | SharePoint | For business | Windows
0 comments No comments
{count} votes

Accepted answer
  1. ZhengyuGuo 10,586 Reputation points Moderator
    2021-04-29T01:59:57.61+00:00

    Hi @MaeshCM-7927,

    From your description, I understand you will firstly got the id data which return from another api call and then using in a loop to get SharePoint list data.

    Then you can put get data logic in Success callback like this:

    92374-snipaste-2021-04-29-09-59-11.png

    Thanks
    Best Regards


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.