回答編集履歴
2
テキスト修正
test
CHANGED
@@ -2,7 +2,9 @@
|
|
2
2
|
|
3
3
|
|
4
4
|
|
5
|
+
JSONが返ってきているので、`response.text()` を `response.json()` とすればよいかと思います。
|
6
|
+
|
5
|
-
以下のように修正してみると、いかがでしょうか?
|
7
|
+
ですので、以下のように修正してみると、いかがでしょうか?
|
6
8
|
|
7
9
|
|
8
10
|
|
@@ -12,7 +14,19 @@
|
|
12
14
|
|
13
15
|
```javascript
|
14
16
|
|
17
|
+
fetch('https://opentdb.com/api.php?amount=10')
|
18
|
+
|
15
|
-
response => response.text()
|
19
|
+
.then(response => response.text())
|
20
|
+
|
21
|
+
.then(text => {
|
22
|
+
|
23
|
+
console.log(text);
|
24
|
+
|
25
|
+
console.log(text.results);
|
26
|
+
|
27
|
+
console.log(text.results[0].question);
|
28
|
+
|
29
|
+
});
|
16
30
|
|
17
31
|
```
|
18
32
|
|
@@ -22,7 +36,19 @@
|
|
22
36
|
|
23
37
|
```javascript
|
24
38
|
|
39
|
+
fetch('https://opentdb.com/api.php?amount=10')
|
40
|
+
|
25
|
-
response => response.json()
|
41
|
+
.then(response => response.json())
|
42
|
+
|
43
|
+
.then(json => {
|
44
|
+
|
45
|
+
console.log(json);
|
46
|
+
|
47
|
+
console.log(json.results);
|
48
|
+
|
49
|
+
console.log(json.results[0].question);
|
50
|
+
|
51
|
+
});
|
26
52
|
|
27
53
|
```
|
28
54
|
|
1
テキスト修正
test
CHANGED
@@ -28,11 +28,11 @@
|
|
28
28
|
|
29
29
|
|
30
30
|
|
31
|
-
以下、修正後のコードを jsFiddle に上げたものです。
|
31
|
+
以下、動作確認するために修正後のコードを jsFiddle に上げたものです。
|
32
32
|
|
33
33
|
|
34
34
|
|
35
|
-
- [https://jsfiddle.net/jun68ykt/t85cdwsu/
|
35
|
+
- [https://jsfiddle.net/jun68ykt/t85cdwsu/5/](https://jsfiddle.net/jun68ykt/t85cdwsu/5/)
|
36
36
|
|
37
37
|
|
38
38
|
|