forEachの中で非同期処理で詰まったので備忘録として書く
エラー例
console.log("before_forEach", this.datas);
this.datas.forEach(async(data) => {
//非同期処理
});
console.log("after_forEach", this.datas);
成功例
console.log("before_forEach", this.datas);
for (let data of this.datas){
//非同期処理
});
console.log("after_forEach", this.datas);
forで書き直せば、処理順はうまくいくはず!
参考にしたandより詳しい記事