回答編集履歴

2

ちょうせい

2021/05/12 10:41

投稿

yambejp
yambejp

スコア116835

test CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  window.addEventListener('DOMContentLoaded',async()=>{
6
6
 
7
- const res=await fetch("x.json")
7
+ const res=await fetch("sample.json")
8
8
 
9
9
  .then(x=>x.json())
10
10
 

1

ちょうせい

2021/05/12 10:41

投稿

yambejp
yambejp

スコア116835

test CHANGED
@@ -1,13 +1,21 @@
1
1
  ```javascript
2
2
 
3
- (async()=>{
3
+ <script>
4
4
 
5
- const res=await fetch("sample.json").then(x=>x.json()).then(x=>[...new Set(x.map(x=>Object.values(x)).flat())]);
5
+ window.addEventListener('DOMContentLoaded',async()=>{
6
6
 
7
+ const res=await fetch("x.json")
8
+
7
- console.log(res);
9
+ .then(x=>x.json())
10
+
11
+ .then(x=>[...new Set(x.map(x=>Object.values(x)).flat())]);
12
+
13
+ res.forEach(x=>document.querySelector('.categorylist').innerHTML+=`<li>${x}</li>`);
8
14
 
9
15
  })()
10
16
 
17
+ </script>
11
18
 
19
+ <div class="categorylist"></div>
12
20
 
13
21
  ```