Похожие чаты

Thanks man @Injectable() export class SearchService { constructor(private http: Http) {}

search(term: string) {
return this.http
.get('https://api.spotify.com/v1/search?q=' + term + '&type=artist')
.map(response => response.json());
}
}
can i convert into something like this

const API_URL = ''https://api.spotify.com/v1/seach/:query/:type"

@Injectable()
export class SearchService {

constructor(private http: Http) {}

search(term: string) {
return this.http
.get(API_URL, {
query: 'myartis',
type: 'rocks'
})
.map(response => response.json());
}
}
refer this https://angular-2-training-book.rangle.io/handout/http/making_requests.html

1 ответов

20 просмотров

Why you just change from const to let ? And construct URL before making request

Похожие вопросы

Карта сайта