【问题标题】:Angular 5 http POST call not triggeringAngular 5 http POST 调用未触发
【发布时间】:2018-09-06 02:59:23
【问题描述】:

http post call 没有从我的应用程序触发。请检查下面的 http post call 代码

getTables(): Observable<any[]> {
      return this.http.post<any[]>('http://zltstesasweb01.phs.org:7980/SASBIWS/rest/storedProcesses/Web/hsd3_hsd_pcp_try_111/dataTargets/WEBOUT','<stp><parameters><selFilter>V</selFilter></parameters></stp>',httpOptions);
}

请在下方查看我的订阅方法

this.constantdataService.getTables().subscribe(dataobj =>{
  console.log(dataobj);
});

我在控制台中收到以下错误。

我也无法在我的网络标签中看到通话后

【问题讨论】:

  • 不要发布错误图片。粘贴错误的文本,以便人们可以搜索。

标签: angular http-post angular5 angular-cli httpclient


【解决方案1】:

“angular-in-memory-web-api”的问题。 In-memory-web-api 正在阻止真正的 API 调用它在本地数据服务中的搜索。当我在 app.module.ts 的配置中添加 passThruUnknownUrl: true 时。它开始工作了。

@NgModule({
imports: [
  ....
  HttpClientModule,
  ...
  HttpClientInMemoryWebApiModule.forRoot(
    LocaldatasericeService,{ dataEncapsulation: false,
    passThruUnknownUrl: true }
  )
  ...
]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-01-18
    • 2021-12-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-05
    • 2018-08-04
    相关资源
    最近更新 更多