Advertisement
vecio88

Subscribe

May 12th, 2021
1,213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.   getCampionati() {
  2.  
  3.     const URL_LISTA_CAMPIONATI : string = "http://api.football-data.org/v2/competitions";
  4.     const campionatiPermessi = [2001, 2019, 2021, 2015, 2002, 2013];
  5.  
  6.     const observable = this.http.get(URL_LISTA_CAMPIONATI, {
  7.       headers : {'X-Auth-Token': 'b96d850637b24b5c92df997a3bd9d695'},
  8.       responseType: 'json'
  9.     })
  10.  
  11.     let prova = observable.pipe(
  12.       map(x => x['competitions']),
  13.       switchMap(x => x),
  14.       filter(camp =>  campionatiPermessi.find(x =>  x === camp['id'] ) ? true : false)
  15.     ).subscribe({
  16.       next(val) {
  17.         console.log(val);
  18.       },
  19.       error(err) {
  20.         console.log("Error: " + err);
  21.       },
  22.       complete() {
  23.         console.log("Complete");
  24.       }
  25.     });
  26.  
  27.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement