DEV Community

Discussion on: Javascript: How to access the return value of a Promise object

Collapse
 
sadaf_sajad_d2027c3f81a83 profile image
Sadaf Sajad

Hi, Kate
Can you please help me with this one
i receive data from an axios call collect it in a variable and return it when i call the function i receive data as promise like you showed
i put async await everything you said but this isn't working

$(document).ready(function () {
merchantDetails;
var load = merchantDetails(userName)
console.log(load)
})
merchantDetails = function (userName) {
var axiosResponse = axios.get("/adminMerchantOrderDetails/merchantDetails?username=" + userName).then(function (response) {
let order = response.data.responseData;
return order
console.log((order))
})
return axiosResponse
}

Collapse
 
ramonak profile image
Katsiaryna (Kate) Lupachova

Hi Sadaf! It's kinda hard to understand this unformatted piece of code. Could you please provide a link to a codesanbox, GitHub repo or something like that so I could take a look and try to help you?