0

enter image description here

and this is my code to call api :

apiBaseURL= ${environment.baseUrl}

constructor(private http: HttpClient) { }

getTeams() {

let authToken = {
  "x-rapidapi-key": "ba0a665d73msh8c54a216ac1d6c5p1f80c4jsn312950ace3e0",
  "x-rapidapi-host": "api-football-v1.p.rapidapi.com"
}
const reqHeader = new HttpHeaders({
  'Content-Type': 'application/json',
  'Authorization': `Bearer ${authToken}`
})

return this.http.get('https://api-football- 
v1.p.rapidapi.com/v2/teams/team/33', {headers: reqHeader })

}

amr hamdy
  • 41
  • 3

2 Answers2

0

Make sure to subscribe to API on RapidAPI Hub before using it. This can be the possible reason why you're getting 401 unauthorized response.

If the error still persists after a successful subscription, try adding x-rapidapi-key and x-rapidapi-host as the custom headers.

Pratham
  • 497
  • 3
  • 7
0

Either you haven't subscribed the API, or The key is wrong or The basic plan got expired which gives you 500 requests a month.

check all the above, in case you are doing a learning activity I advice you to signup from a new acc and re subscribe the FREE basic plan (don't forget to change the API key though)

if you are an enterprise, kindly update the plan as free is good enough only till development purposes.

Sourabh
  • 207
  • 2
  • 2