Angular 2 Http.get没有响应

时间:2017-04-17 16:26:58

标签: angular typescript

我使用Http.get来检索配置文件。我成功地做了很多次,但这次没什么。我没有在控制台中看到跟踪,即使我正在使用.catch,我也没有看到错误。这可能是我的问题?

activityStream.foreachRDD { rdd =>
  val activityDF = rdd
    .toDF()
    .selectExpr(
        "timestamp_hour", "referrer", "action", 
        "prevPage", "page", "visitor", "product", "inputProps.topic as topic")
    val producerRecord = new ProducerRecord(topicc, activityDF)

    kafkaProducer.send(producerRecord) // <--- this shows an error 
  }

2 个答案:

答案 0 :(得分:3)

您需要 subscribe() 才能接收数据

   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);
    }

答案 1 :(得分:2)

您需要调用subscribe()才能执行请求。

相关问题