1つ目のAPIを実行してうまく通った場合にのみ、
次のAPIを実行するような処理を実装する一例。
※下記のサンプルではVuex、Axiosで実装しています
index.js
async getData({ commit, state }) {
try {
await this.$axios.
$get('URI')
.then(() => {
this.$axios
.$get('URI')
.then((resp) => {
commit('setData', resp)
})
.catch((error) => {
console.log(error)
})
} catch((error) => {
console.log(error)
})
} catch (error) {
console.log(error) [
}
}
}
Actiosの中での実装を想定しているので、
commitでMutationsにある(想定)setDataにデータを渡しています。