Usage of AP.request

add-on
jira-plugin
jira-cloud
atlassian-connect

#1

Is AP.request synchronous/asynchronous? If synchronous how can I turn it to false(asynchronous) or vice-versa?


#2

Updated answer

I have just learned that AP.request already returns a promise. So you can just:

const myResponse = await AP.request('/rest/api/3/mypermissions');

Original answer

AP.request is asynchronous. You could wrap it in a promise and then use async / await to emulate synchronous behaviour.

For example:

new Promise((resolve, reject) => {
  AP.request('/rest/path/to/api', {
    success: function(responseText){
      resolve(responseText);
    },
    error: function(xhr, statusText, errorThrown){
       reject(arguments);
    }
  })
});

See: https://developer.atlassian.com/cloud/jira/platform/jsapi/request/