I have the following function which takes a key as parameter, then I pass this key in Rest call. The rest call gives me JSON reply and I filter out the appropriate response I need.
function getWorkflowScehmeName(projectKey){
var restCall = AJS.params.baseURL+"/rest/projectconfig/1/workflowscheme/"+projectKey
var workflowSchemeName
AJS.$.get(restCall, function(response){
if(response != null){
workflowSchemeName = response.name
}
console.log(workflowSchemeName)
return workflowSchemeName
})
return workflowSchemeName
}
Now there are multiple keys which I need to pass and need to store their appropriate responses. In the following piece of code, I'm making a list of pairTypeValues which will store the keys and the responses against them.
pairTypeValues = {}
AJS.$.each(AJS.$(".projects-list tr td:nth-child(3)"), function(index, value){
pairTypeValues[value.innerText] = getWorkflowScehmeName(value.innerText)
})
But the values in PairTypeValues are all Undefined against the their keys. How can I get the responses back and store them successfully? How do I write a callback for this?
Can anyone help, Many thanks in advance.