非同期処理

awaitとthenの挙動と使い分け、awaitを使わないほうが良い場合とPromise.all()について

awaitの使用例 まずdeveloper.mozillaの説明を引用しますと await 演算子は、async function によって Promise が返されるのを待機するために使用します。 下の例ではawait processA()でprocessAの解決を待ったあとに以下の処理が走ります。 processA()の実…

CallBackのネスト地獄をasync/await でリファクタリングするメモ

リファクタリング対象コード anyMethoid(){ this.returnPromiseMethod1().then(result1 => { if (result1.data) { // result1を取得してからしたい何かの処理... this.returnPromiseMethod2().then(result2 => { if (result2.data) { // result1とresult2を…