To eliminate confusion with promises, my preference lies in utilizing the "await" command and async functions.
For this scenario, I would establish an asynchronous function initially, which will replace the anonymous function invoked within the "promise.then" section of this query:
async function SubFunction(output){
// Request made to database, resulting in a promise, similar to an Ajax call:
const response = await axios.get( GetApiHost() + '/api/some_endpoint')
// Response:
return response;
}
Subsequently, I would invoke this function within the main function:
async function justTesting() {
const lv_result = await SubFunction(output);
return lv_result + 1;
}
Note that both the main function and sub function have been transformed into async functions in this context.