Ok, so I'm trying to modify a piece of existing code in a function I'm working on to integrate a database call to check for information stored there instead of just locally as is currently default in the library (commando.js).
The problem is, the database call is handled through a promise with sequelize. I need to return values from the .then() somehow to the parent function/scope? I know you can do this with async/await but because the function is part of a class that extends one from the library, it can't be an async function. Is there a way to return the value from .then() to the parent scope or is that simply not possible?
I've tried to use callbacks and they get the value back out to the parent scope but the function finishes executing before the callback returns so I don't think that'll work unless there's a way to wait for the callback to return?
Here's what I currently have:
nonAsyncFunction(args){
// Do stuff
database.getData()
.then((result)=>{
// Do Stuff
return value
});
return value // Need to somehow return value from .then() here?
}
If you have any questions or need any info from me feel free to let me know, otherwise thanks so much in advance for the help.