Angular 2 Http.get not responding

前端 未结 2 1013
离开以前
离开以前 2021-01-21 14:07

I\'m using Http.get to retrieve a configuration file. I\'ve done this many times with success, but this time nothing. I\'m not seeing the trace in my console, and I\'m not seein

相关标签:
2条回答
  • 2021-01-21 14:40

    You need to have subscribe() in order to recieve the data

       this._http.get('./assets/dashboard/json/config.json')
            .map(res => res.json())
            .subscribe(
              data => this.ResResponse= data,
              err => this.logError(err),
              () => console.log('Completed')
            ); 
    
        logError(err) {
          console.error('There was an error: ' + err);
        }
    
    0 讨论(0)
  • 2021-01-21 15:00

    you need to call subscribe() in order that the request is executed.

    0 讨论(0)
提交回复
热议问题