I have method dropDowndata that is being called on page load and it is rendering dropdownbData so in getClientList
i got the response from api call however when i am trying to call getCLientList
in dropdDownData
it shows Promise is pending and that result in undefined data
. what is implemented wrong in below code ? How to resolve axios promise ?
main.js
function dropdDowndata() {
var _env = getEnv();
var data;
getClientList().then(function(response) {
data = response;
});
};
function getClientList = function() {
debugger;
var resetResponse = "";
var refId = GUIDUtil.Guid.newGuid().toString("N");
var details = {};
var params = {
"Request": {
"header": {
"serviceContext": {
"apiVersion": "1.0",
"lineOfBusiness": "SPD"
},
"securityContext": {
"securityType": "apiKey",
"apiKey": "26283629239362127"
}
},
"details": details
}
};
var clientListParams = {
url: getHostName() + '/test/client',
data: params,
method: 'POST',
headers: {
'Content-Type': 'application/json'
}
};
return axios(clientListParams).then(function(response) {
return response.data;
}).catch(error);
};