-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloveWords.js
More file actions
25 lines (25 loc) · 764 Bytes
/
loveWords.js
File metadata and controls
25 lines (25 loc) · 764 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*!
* Filename: loveWords.js
* Edition: V1.0.1
* Author: MingTechPro
* Blog:
* Copyright © 2024 MingTechPro.
* License: MIT & CC BY 4.0
*/
fetch('https://api.uomg.com/api/rand.qinghua')
.then(response => {
if (!response.ok) {
throw new Error('The network response is abnormal: ' + response.statusText);
}
return response.json();
})
.catch(error => {
console.error('There is a problem with your fetch operation: ', error);
})
.then(data => {
if (document.getElementById("love_words_text")) {
document.getElementById("love_words_text").innerHTML = data.content;
} else {
console.error("找不到 ID 为 love_words_text 的元素!");
}
});