简体   繁体   English

Angular 5 http POST 调用未触发

[英]Angular 5 http POST call not triggering

http post call is not triggering from my application. http post 调用不是从我的应用程序触发的。 Please check the below code for http post call请检查以下代码以进行http post调用

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

Please check below my subscribe method请检查下面我的订阅方法

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

I am getting the below error in console.我在控制台中收到以下错误。

在此处输入图片说明

I am not able to see the post call in my network tab as well我也无法在我的网络选项卡中看到帖子调用

在此处输入图片说明

If you actually look at the network tab, the call is triggered, it just that the url is wrong. 如果您实际上查看“网络”选项卡,则会触发该调用,只是URL错误。

You need to verify if the url is correct and it seems you are sending an xml as a string in the input, it should be a json, well that depends on the API. 您需要验证url是否正确,并且似乎要在输入中以字符串形式发送xml,它应该是json,这取决于API。

The issue with 'angular-in-memory-web-api'. 与“ angular-in-memory-web-api”有关的问题。 In-memory-web-api is blocking the real API call its searching in the localdata services. In-memory-web-api阻止了在localdata服务中进行搜索的真实API调用。 when I am adding the passThruUnknownUrl: true in configuration of app.module.ts. 当我在app.module.ts的配置中添加passThruUnknownUrl:true时。 its started working. 它开始工作。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM