I don't backend and need to make an API with api-key in the header.
This is the route which was pointed from the client:
public static async getPlayer(req: Express.Request, res: Express.Response) {
try {
const contestantId = req.query.id;
const playerData = await DataStatisticsService.getPlayerData(contestantId);
res.send(playerData);
} catch (err) {
ErrorHandler.handle('Error fetching player data', err, res);
}
}
This API call getPlayerData(contestantId);
should send request with header which have api-key:
public static async getPlayerData(contenstantId: string): Promise<any> {
const url = `${BASE_URL}/api/sports/football/players/${contenstantId}/data`;
const response: Promise<any> = (await axios.get(url)).data;
return response;
}
How to add header with api-key for this request getPlayerData()
?