【发布时间】:2020-04-21 04:10:52
【问题描述】:
在使用 get 发送端点时,我添加了它返回值的主体,但是如果我使用 httpcliente 使用 angular 执行此操作,这不会向我显示使用 spring boot 消耗后端的主体
Cosuming with postman and httpCliente
header = new HttpHeaders().set('Authorization', this.auth.isToken())
.set('Content-Type', 'application/json')
.set('Accept-Language', 'UTF-8')
.set('Cache-Control', 'no-cache');
const url = 'api/servicios/servicios-impuestos-clientes';
const object = JSON.stringify(body);
const options = {
headers: this.header,
body: JSON.stringify({ 'impuestos' [1, 2] }),
// tslint:disable-next-line: quotemark
// tslint:disable-next-line: object-literal-shorthand
params: new HttpParams().append('cliente', 1 + '')
};
console.log(options);
return this.http.get<Servicios>(url, options).pipe(map(result => {
return result;
}));
【问题讨论】:
-
您可以在
HTTPGET请求中传递参数,发送正文需要使用POST请求。 -
那么,邮递员允许通过get方法发送body,但是httpClient不允许,对吧?
标签: angular typescript spring-boot httpclient angular9