回答編集履歴
3
求めているものではない気がしてきたので削除
test
CHANGED
@@ -69,35 +69,3 @@
|
|
69
69
|
})
|
70
70
|
|
71
71
|
```
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
---
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
# 追記
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
私が書くなら、オブジェクトをまとめてしまうかもですね。
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
```js
|
88
|
-
|
89
|
-
Promise.all(url.map(async ([endpoint, dataUrl]) => [endpoint,
|
90
|
-
|
91
|
-
await fetch(dataUrl, {
|
92
|
-
|
93
|
-
method: "GET",
|
94
|
-
|
95
|
-
})
|
96
|
-
|
97
|
-
.then(response => response.json())
|
98
|
-
|
99
|
-
]))
|
100
|
-
|
101
|
-
.then(x => console.log(Object.fromEntries(x).onecall.hourly[0].temp))
|
102
|
-
|
103
|
-
```
|
2
追記
test
CHANGED
@@ -69,3 +69,35 @@
|
|
69
69
|
})
|
70
70
|
|
71
71
|
```
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
---
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
# 追記
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
私が書くなら、オブジェクトをまとめてしまうかもですね。
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
```js
|
88
|
+
|
89
|
+
Promise.all(url.map(async ([endpoint, dataUrl]) => [endpoint,
|
90
|
+
|
91
|
+
await fetch(dataUrl, {
|
92
|
+
|
93
|
+
method: "GET",
|
94
|
+
|
95
|
+
})
|
96
|
+
|
97
|
+
.then(response => response.json())
|
98
|
+
|
99
|
+
]))
|
100
|
+
|
101
|
+
.then(x => console.log(Object.fromEntries(x).onecall.hourly[0].temp))
|
102
|
+
|
103
|
+
```
|
1
コメントを受けて追記
test
CHANGED
@@ -27,3 +27,45 @@
|
|
27
27
|
})
|
28
28
|
|
29
29
|
```
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
---
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
# コメントを受けて追記
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
こうですか?
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
```js
|
46
|
+
|
47
|
+
let url = [["forecast", url1], ["timemachine", url2], ["onecall", url3]];
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
url.forEach(function ([endpoint, dataUrl]) {
|
52
|
+
|
53
|
+
fetch(dataUrl, {
|
54
|
+
|
55
|
+
method: "GET",
|
56
|
+
|
57
|
+
})
|
58
|
+
|
59
|
+
.then(response => response.json())
|
60
|
+
|
61
|
+
.then(json => {
|
62
|
+
|
63
|
+
if (endpoint === "timemachine") console.log(json["hourly"][0]["temp"]);
|
64
|
+
|
65
|
+
if (endpoint === "onecall") console.log(json["hourly"][0]["temp"]);
|
66
|
+
|
67
|
+
})
|
68
|
+
|
69
|
+
})
|
70
|
+
|
71
|
+
```
|