Array prototype methods don't await even if they are async. The code fires in a synchronous manner still. If you need these to await you can do
const subcategories = articleDto.subcategoriesIds.split(',').map(x => +x)
const subcategoriesList = []
for (const subCategoryId of subcategories) {
console.log('start:' + subcategoryId)
const category = await this.subcategoriesService.getSubcategoryById(subcategoryId);
console.log('mid:' + subcategoryId)
await subcategoriesList.push(category);
console.log('end:' + subcategoryId);
}
console.log('### ' + subcategories);
console.log('### ' + subcategoriesList);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…