In JS, A function Main
has 2 functions inside it. The second function should be executed after first function finishes the API call and has returned some value. How do I call the function secondFunction
only after firstFunction
returns any value and also be able to pass the value returned to the secondFunction
.
function Main(ID) {
firstFunction(ID)
secondFunction()
}
function firstFunction(ID) {
//async call
}
function secondFunction(value) {
console.log(value)
return value
}