teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

変更

2018/08/14 02:34

投稿

退会済みユーザー
answer CHANGED
@@ -23,6 +23,6 @@
23
23
  }, reason => {
24
24
  console.error(reason)
25
25
  })
26
- }
26
+ },
27
27
  }
28
28
  ```

1

追記

2018/08/14 02:34

投稿

退会済みユーザー
answer CHANGED
@@ -1,2 +1,28 @@
1
1
  `getClientName()` 内の `_.find()` が `undefined` を返しているようです。
2
- `getClientName()` に渡される `cid` の値は `this.clients` のどれかに必ず一致しますか?
2
+ `getClientName()` に渡される `cid` の値は `this.clients` のどれかに必ず一致しますか?
3
+
4
+ ### 追記
5
+
6
+ `axios` は `Promise` ベースの API です。
7
+ `Promise.all()` を使用すれば、すべてのレスポンスを一度に受け取ることができます。
8
+ 以下のコードを試してみてください。
9
+
10
+ ```js
11
+ export const actions = {
12
+ load(ctx) {
13
+ Promise.all([
14
+ axios.get("https://api.airtable.com/v0/appxxxxxxxxx/works?api_key=keyxxxxxxxxxxxxxxxx"),
15
+ axios.get("https://api.airtable.com/v0/appxxxxxxxxx/clients?api_key=keyxxxxxxxxxxxxxxxx"),
16
+ axios.get("https://api.airtable.com/v0/appxxxxxxxxx/agency?api_key=keykeyxxxxxxxxxxxxxxxx"),
17
+ ])
18
+ .then(responses => {
19
+ console.log(responses)
20
+ ctx.commit('setWorks', responses[0].data.records)
21
+ ctx.commit('setClients', responses[1].data.records)
22
+ ctx.commit('setAgencies', responses[2].data.records)
23
+ }, reason => {
24
+ console.error(reason)
25
+ })
26
+ }
27
+ }
28
+ ```