这是正确的方法
import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http'; sendPostRequest(){ const httpOptions = { headers: new HttpHeaders({ "Content-Type": "application/json" }), params: extraParams }; return this.http.post("url", bodydata); } //call method callPostmethod(){ sendPostRequest.subscribe((response)=>{ //success console.log("success"+JSON.stringify(response)); }, (error)=>{ //error console.log("erorr"+JSON.stringify(error)); }) }