HttpClient.post()和新的HttpRequest(' POST')之间的区别是什么?

时间:2017-12-06 05:35:19

标签: angular httprequest httpclient

我最近正在学习角度,我发现有两种方法可以发出POST请求:



constructor(private httpClient: HttpClient) {
  httpClient.post(url, data, options);
}

constructor(private httpClient: HttpClient) {
  const req = new HttpRequest('POST', url, init);
  httpClient.request(req);
}




所以我想知道它们之间有什么不同。或者他们只是两种方式来执行HTTP请求

1 个答案:

答案 0 :(得分:1)

select ID, A = LEFT(cast(a as varchar(100)+'00000000',8), b = LEFT(cast(b as varchar(100)+'00000000',8), C = LEFT(cast(c as varchar(100)+'00000000',8) from xyz 函数实际上只是一个辅助函数,相当于post()

检查https://github.com/angular/angular/blob/master/packages/common/http/src/client.tsrequest('POST', ...)调用post()的来源,在传入字符串request('POST')时创建HttpRequest对象。它不是就像那样简单,因为它根据选项等连接了可观察量,但这就是它本质上的含义。