xiongxiao a révisé ce gist . Aller à la révision
1 file changed, 19 insertions
say.html(fichier créé)
| @@ -0,0 +1,19 @@ | |||
| 1 | + | <body> | |
| 2 | + | <div id="content"></div> | |
| 3 | + | <script> | |
| 4 | + | const url = new URL('/api/v1/saying', 'https://uapis.cn/'); | |
| 5 | + | const res = fetch(url, { | |
| 6 | + | method: 'GET', | |
| 7 | + | headers: { | |
| 8 | + | 'Content-Type': 'application/json', | |
| 9 | + | }, | |
| 10 | + | }).then(response => response.json()) | |
| 11 | + | .then(data => { | |
| 12 | + | console.log(data); | |
| 13 | + | document.getElementById('content').innerText = data.text; | |
| 14 | + | }) | |
| 15 | + | .catch(error => { | |
| 16 | + | console.error('Error fetching data:', error); | |
| 17 | + | }); | |
| 18 | + | </script> | |
| 19 | + | </body> | |
Plus récent
Plus ancien