第二个参数为
http.post
是内容正文。您可以通过以下方式传递URL参数:
const urlParams = new HttpParams()
.set('payload', 'testing...');
return this.http.post<String>(`${this.loginUrl}?${urlParams}`, '',{headers: this.headers});
如果要将url参数传递到正文中,则:
login(credentials): Observable<String> {
const body = new HttpParams()
.set('payload', 'testing...');
let bodyValue = body.toString()
return this.http.post<String>(this.loginUrl, bodyValue,{headers: this.headers})
}