In the scenario presented, there is an attempt to pass the constant filter
into the Promise.all
function, but the method of passing it down is proving to be a challenge, resulting in it being undefined in the final line of code.
What is the best way to pass the variable into the Promise.all
function?
if (query.filter) {
const dynamicFilter = '&filter=' + query.filter;
} else {
const dynamicFilter = '';
}
const [companyResponse, requestsResponse] = await Promise.all([
// Performing an API Call to "Read a company"
$axios.$get('/companies/' + params.company),
// Performing an API Call to "List a company's requests"
$axios.$get('/companies/' + params.company + '/requests?count=5&include=owner' + dynamicFilter)
]);