-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi-test.js
28 lines (22 loc) · 836 Bytes
/
api-test.js
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
26
27
28
const axios = require('axios');
const baseURL = 'http://localhost:3001';
async function testAPI() {
try {
// Start Session
const { data: startData } = await axios.get(`${baseURL}/start`);
console.log("Start Session:", startData);
const sessionId = startData.sessionId;
// Fetch Scrambled Word
const { data: wordData } = await axios.get(`${baseURL}/word/${sessionId}`);
console.log("Scrambled Word:", wordData);
// Make a Guess
const { data: guessData } = await axios.get(`${baseURL}/guess/${sessionId}/${wordData.scrambledWord}`);
console.log("Check Guess:", guessData);
// End Session
const { data: endData } = await axios.get(`${baseURL}/end/${sessionId}`);
console.log("End Session:", endData);
} catch (error) {
console.error("API Error:", error);
}
}
testAPI();