Skip to content

Instantly share code, notes, and snippets.

@2014maximo
Created June 11, 2019 21:53
Show Gist options
  • Save 2014maximo/53d36bff51ac709ae5a25b9324395c63 to your computer and use it in GitHub Desktop.
Save 2014maximo/53d36bff51ac709ae5a25b9324395c63 to your computer and use it in GitHub Desktop.
@@@@@ @
@ @
@ @@@@ @ @@@ @@@@
@ @@ @@ @ @@ @ @@ @
@ @ @ @ @ @@@@@ @ @
@ @ @ @@ @ @ @
@ @@ @@ @ @ @@ @ @
@ @@@@ @ @ @@@@ @ @
//EN EL SERVICIO
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
@Injectable({
providedIn: 'root'
})
export class SpotifyService {
constructor(private http: HttpClient) {
console.log('Spotify Service listo');
}
getNewReleases(){
const headers = new HttpHeaders({
'Authorization': 'Bearer BQDerv7OUUzUZZmmOh5LLP3QTrXa9EYIpyClps5PoqE8wK5MesEq1v0KcGSgNUwSVYc3Q7EYmzPK3a1EIvo'
});
this.http.get('https://api.spotify.com/v1/browse/new-releases', { headers })
.subscribe(data => {
console.log(data);
});
}
}
//EN EL elemento.component.ts:
import { Component, OnInit } from '@angular/core';
import { SpotifyService } from '../../services/spotify.service';
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styles: []
})
export class HomeComponent {
constructor( private spotify: SpotifyService ) {
this.spotify.getNewReleases();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment