Forge handling more than 10 req in runtime

Hello everyone, I am developing Jira Cloud application with React and Forge. I have a big problem with limitations. I need to get more than 10 issue at same time but sometimes it works, sometimes not. Whenever I choose a something, It has to send request for getting all issues. It might be 5 issues or 25 issues. When I need to get more than 10 issues, It returns 429.

Also, In runtime, 5 or 6 requests work at the same time. Again, It crashes the application.

Little example about getting issues:

invoke("tableName", projectKey).then((data) => {
        for (let j = 0; j < data.length; j++) {
          const methodIdFromSavedData = data[j].tableDataToSend.methodId;
          setLoading(true);
          if (methodIdFromSavedData === selectedMethodId) {
            const issuesArray = data[j].tableDataToSend.issuesArray;

            if (issuesArray.length > 0) {
              issuesArray.forEach(function (item, i) {
                requestJira(
                  "/rest/api/3/issue/" + issuesArray[i].issueKey
                ).then((response) => {
                  const stringifiedData = JSON.stringify(response);
                  const parsedData = JSON.parse(stringifiedData);
                  var mergedObj = { ...parsedData.body, ...issuesArray[i] };

                  setSelectedIssueInformation((prevValue) => {
                    return [mergedObj, ...prevValue];
                  });
                  setLoading(false);
                });
              });
            }
          } else {
            setLoading(false);
            setWarning(true);
            setSelectedIssueInformation("");
          }
        }
      });

I need to handle these limitations asap. Thanks in advance.

I would suggest switching to the /rest/api/3/search end point and do a jql of “key in (…)” and replacing the … with the issue keys. That way you only have to fetch one set of items.

Thank you for your suggestion, It worked!

If anyone needs query:

 `/rest/api/3/search?jql=key in (XXX-1,XXX-2,XXX-3,XXX-4.......)`

Note: it’s better to avoid parallel API requests, then you should never hit 429 response, see Rate limiting