-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtestBackend.js
More file actions
49 lines (42 loc) ยท 1.89 KB
/
Copy pathtestBackend.js
File metadata and controls
49 lines (42 loc) ยท 1.89 KB
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// ๋ฐฑ์๋ API ํ
์คํธ ์คํฌ๋ฆฝํธ
const fetch = require('node-fetch');
const BASE_URL = 'http://api.hjun.kr/hackathon';
async function testCharacterAPIs() {
console.log('๐งช ๋ฐฑ์๋ API ํ
์คํธ ์์...\n');
try {
// 1. ์บ๋ฆญํฐ ๋ชฉ๋ก ์กฐํ
console.log('1. ์บ๋ฆญํฐ ๋ชฉ๋ก ์กฐํ (/characters/)');
console.log('โ'.repeat(50));
const listResponse = await fetch(`${BASE_URL}/characters/`);
const listData = await listResponse.json();
console.log('Status:', listResponse.status);
console.log('Total images:', listData.total);
console.log('First few images:');
if (listData.images && listData.images.length > 0) {
listData.images.slice(0, 3).forEach((img, idx) => {
console.log(` ${idx + 1}. ${img.category} - ${img.characterInfo?.name || 'Unknown'} - ${img.url}`);
});
}
console.log('\n');
// 2. ํน์ ์บ๋ฆญํฐ ์ ๋ณด ์กฐํ
console.log('2. ์บ๋ฆญํฐ ์ ๋ณด ์กฐํ (/characters/char-crybaby/info)');
console.log('โ'.repeat(50));
const infoResponse = await fetch(`${BASE_URL}/characters/char-crybaby/info`);
const infoData = await infoResponse.json();
console.log('Status:', infoResponse.status);
console.log('Response:', JSON.stringify(infoData, null, 2));
console.log('\n');
// 3. ์บ๋ฆญํฐ ์ด๋ฏธ์ง ์กฐํ
console.log('3. ์บ๋ฆญํฐ ์ด๋ฏธ์ง ์กฐํ (/characters/char-crybaby/0)');
console.log('โ'.repeat(50));
const imageResponse = await fetch(`${BASE_URL}/characters/char-crybaby/0`);
console.log('Status:', imageResponse.status);
console.log('Content-Type:', imageResponse.headers.get('content-type'));
console.log('Image URL:', `${BASE_URL}/characters/char-crybaby/0`);
console.log('\n');
} catch (error) {
console.error('โ ํ
์คํธ ์คํจ:', error.message);
console.error('๋ฐฑ์๋ ์๋ฒ๊ฐ ์คํ ์ค์ธ์ง ํ์ธํ์ธ์!');
}
}
testCharacterAPIs();