81 lines
2.5 KiB
JavaScript
81 lines
2.5 KiB
JavaScript
// Test PPoint Service trực tiếp với token có sẵn
|
|
// Chạy trong browser console tại http://localhost:3001
|
|
|
|
console.log('🧪 Testing PPoint Service with existing token...');
|
|
|
|
// Kiểm tra token
|
|
const token = localStorage.getItem('auth_token');
|
|
console.log('🔍 Token status:', token ? '✅ Found' : '❌ Missing');
|
|
|
|
if (!token) {
|
|
console.error('❌ No token found! Please login first.');
|
|
return;
|
|
}
|
|
|
|
// Test API trực tiếp
|
|
async function testPPointAPI() {
|
|
try {
|
|
console.log('🔍 Testing API endpoints directly...');
|
|
|
|
// Test balance endpoint
|
|
const balanceResponse = await fetch('http://localhost:7009/api/points/balance', {
|
|
method: 'GET',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'Authorization': `Bearer ${token}`
|
|
}
|
|
});
|
|
|
|
console.log('💰 Balance API Status:', balanceResponse.status);
|
|
if (balanceResponse.ok) {
|
|
const balanceData = await balanceResponse.json();
|
|
console.log('✅ Balance API working!', balanceData);
|
|
} else {
|
|
const errorData = await balanceResponse.json();
|
|
console.error('❌ Balance API error:', errorData);
|
|
}
|
|
|
|
// Test daily points status
|
|
const dailyResponse = await fetch('http://localhost:7009/api/daily-points/status', {
|
|
method: 'GET',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'Authorization': `Bearer ${token}`
|
|
}
|
|
});
|
|
|
|
console.log('📅 Daily Points API Status:', dailyResponse.status);
|
|
if (dailyResponse.ok) {
|
|
const dailyData = await dailyResponse.json();
|
|
console.log('✅ Daily Points API working!', dailyData);
|
|
} else {
|
|
const errorData = await dailyResponse.json();
|
|
console.error('❌ Daily Points API error:', errorData);
|
|
}
|
|
|
|
// Test transaction history
|
|
const historyResponse = await fetch('http://localhost:7009/api/points/history?offset=0&limit=10', {
|
|
method: 'GET',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'Authorization': `Bearer ${token}`
|
|
}
|
|
});
|
|
|
|
console.log('📊 History API Status:', historyResponse.status);
|
|
if (historyResponse.ok) {
|
|
const historyData = await historyResponse.json();
|
|
console.log('✅ History API working!', historyData);
|
|
} else {
|
|
const errorData = await historyResponse.json();
|
|
console.error('❌ History API error:', errorData);
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('❌ Test error:', error);
|
|
}
|
|
}
|
|
|
|
// Run test
|
|
testPPointAPI();
|