Addon.httpclient not updating global variable

Hi Team,

I am calling addon.httpclient to call rest API of JIRA, please check the below code

but here it’s not updating data value after printing on console its showing undefined.

did I am missing something here?

async function getAllProjects(req, ts)
{
let data;
return new Promise((resolve, reject) => {
plugin.httpClient(req)
/.asUserByAccountId(userAccountId)/
.get(“rest/api/3/project?”, function(err, response, body)
{
data = JSON.parse(body);
if (err) reject(err);
resolve(data);
});
console.log(data+">>>>>>>>>>>>>>>>>>>>>>>>>>>"+JSON.stringify(data));
return data;
});

Any Help on this, please.
Thanks in advance.

Hello,

Any response on this please.

This should work fine as I have verified it myself. Could you please make sure that whichever route you are calling this function from, that route is secured with JWT using plugin.authenticate()? You can read more about it here - https://bitbucket.org/atlassian/atlassian-connect-express/src/master/

Otherwise, the above function is perfectly fine.