Javascript 函数未在Angular2上执行

Javascript 函数未在Angular2上执行,javascript,angular,typescript,web,frontend,Javascript,Angular,Typescript,Web,Frontend,当按钮单击触发createPlaylist()时,函数无法执行asd()。我试着在同一个函数上做这一切,但得到的结果是一样的。console.log(resp)从不记录日志。为什么呢 createPlaylist(token:string = localStorage.getItem('myToken')) { const url = `https://api.spotify.com/v1/users/${this.currentUser}/playlists`;

当按钮单击触发createPlaylist()时,函数无法执行asd()。我试着在同一个函数上做这一切,但得到的结果是一样的。console.log(resp)从不记录日志。为什么呢

    createPlaylist(token:string = localStorage.getItem('myToken')) {

      const url = `https://api.spotify.com/v1/users/${this.currentUser}/playlists`;
      const headers = new Headers();
      headers.append('Authorization', 'Bearer ' + token);
      headers.append('Content-Type', 'application/json');
      const body = {
        'name': 'searchDDD playlist'
      };
      this.http.post(url, body, { headers } )
      .subscribe(res => {
        console.log(res.json().name);
        console.log(res.status);
        this.playlistID = res.json().id;
        this.asd();
      });


    }

    asd(token:string = localStorage.getItem('myToken')){
      const url = `https://api.spotify.com/v1/users/${this.currentUser}/playlists/${this.playlistID}/tracks?`;
      const body = {'uris': ['spotify:track:4iV5W9uYEdYUVa79Axb7Rh',
      'spotify:track:1301WleyT98MSxVHPZCA6M']};
      const headers = new Headers();
      headers.append('Authorization', 'Bearer ' + token);
      headers.append('Content-type', 'application/json');
      this.http.post(url, body, { headers } ).map(resp => {
        console.log(resp);
    });
}
如果没有
subscribe()
(或
forEach()
或其他一些实际执行可观察对象的方法),可观察对象将不会做任何事情,因为它们是懒惰的

this.http.post(url, body, { headers } ).subscribe(resp => {
    console.log(resp);
});
可能重复的