feature team search
This commit is contained in:
@@ -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;
|
||||
Reference in New Issue
Block a user