I'm trying to use callback function in node js so I pass variable and callback function like this:
if(true){
await this.serialNumber(customer, async serial => {
console.log(serial); // it's log 43435543
});
// I need to use that serial out of the scope of that function by passing it to this new function
await this.storeinDB(customer, serial);
}
// this is the function where pass variable to callback function
async serialNumber(customer, callback){
const serial = "43435543";
callback(serial);
}
Is there a way to do that?