feature team search

This commit is contained in:
VinceC
2025-01-04 05:26:57 -06:00
parent 75a3b3b52d
commit 8a0f8f1137
4 changed files with 179 additions and 0 deletions

View File

@@ -69,6 +69,38 @@ class PlayerService {
getStatsUrl(username) {
return `${this.baseUrl}/profile/${username}/stats`;
}
async findTeamByName(teamName, gameFilter = null) {
try {
console.log(`Fetching team data for: ${teamName}${gameFilter ? ` in ${gameFilter}` : ''}`);
const url = `${this.baseUrl}/api/get_team_data_by_name/${encodeURIComponent(teamName)}`;
console.log(`API URL: ${url}`);
const response = await axios.get(url, {
timeout: 5000
});
console.log('API Response:', JSON.stringify(response.data, null, 2));
if (response.data && response.data.success) {
// Filter teams by game if gameFilter is provided
if (gameFilter && response.data.teams) {
response.data.teams = response.data.teams.filter(
team => team.game_name.toLowerCase() === gameFilter.toLowerCase()
);
}
}
return response.data;
} catch (error) {
console.error('Error fetching team data:', {
message: error.message,
response: error.response?.data,
status: error.response?.status
});
return null;
}
}
}
module.exports = PlayerService;