-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug-simple.js
More file actions
46 lines (41 loc) · 1.78 KB
/
debug-simple.js
File metadata and controls
46 lines (41 loc) · 1.78 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
const axios = require('axios');
async function test() {
console.log('--- Starting Debug Test ---');
// Test 1: Native Fetch
try {
console.log('\n1. Testing with native fetch...');
const response = await fetch('https://api.dexscreener.com/latest/dex/search?q=SOL');
const data = await response.json();
console.log('Fetch Status:', response.status);
console.log('Fetch Pairs Found:', data.pairs ? data.pairs.length : 0);
} catch (error) {
console.error('Fetch Error:', error.message);
}
// Test 2: Axios
try {
console.log('\n2. Testing with Axios...');
const response = await axios.get('https://api.dexscreener.com/latest/dex/search?q=SOL');
console.log('Axios Status:', response.status);
console.log('Axios Pairs Found:', response.data.pairs ? response.data.pairs.length : 0);
} catch (error) {
console.error('Axios Error:', error.message);
if (error.response) {
console.error('Axios Response Status:', error.response.status);
console.error('Axios Response Data:', error.response.data);
}
}
// Test 3: Axios with User-Agent
try {
console.log('\n3. Testing with Axios + User-Agent...');
const response = await axios.get('https://api.dexscreener.com/latest/dex/search?q=SOL', {
headers: {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
}
});
console.log('Axios+UA Status:', response.status);
console.log('Axios+UA Pairs Found:', response.data.pairs ? response.data.pairs.length : 0);
} catch (error) {
console.error('Axios+UA Error:', error.message);
}
}
test();