I need a simple function that returns the name. Here's my existing code snippet:
getName(entity, id) {
const promise = userServices.getName(entity, id).then((data) => {
return data;
});
//I want to access and return the 'data' value here
}
I am currently working with vue and I understand that I can create another data()
variable, but I prefer not to do so for just one function. Is there an alternative solution? Can I define a variable
within the function that is accessible inside the promise?