-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
23 lines (19 loc) · 876 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
const xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener('readystatechange', function () {
if (this.readyState === this.DONE) {
const responseText = this.responseText;
displayResponse(responseText);
}
});
xhr.open('GET', 'https://wordle-answers-solutions.p.rapidapi.com/today');
xhr.setRequestHeader('X-RapidAPI-Key', 'a7db15b896mshaa0eec529d4db5ep1de9ddjsnd0c01ac55756');
xhr.setRequestHeader('X-RapidAPI-Host', 'wordle-answers-solutions.p.rapidapi.com');
xhr.send();
function displayResponse(responseText) {
const responseObj = JSON.parse(responseText);
const todayWord = responseObj.today;
const formattedWord = todayWord.toUpperCase().charAt(0) + todayWord.toLowerCase().slice(1);
const apiResponseElement = document.getElementById('apiResponse');
apiResponseElement.textContent = formattedWord;
}