[英]How to send this type of body in post request in angular
{ "name": "kiran", "email": "sai123@gmail.com", "phone_number": "123456789", "type": "individual", "billing": { "address":{ "line1":"1234 Main Street", "city":"San Francisco", "state":"CA", "postal_code":"94111", "country": "US" } } } { "name": "kiran", "email": "sai123@gmail.com", "phone_number": "123456789", "type": "individual", "billing": { "address":{ "line1" :"1234 Main Street", "city":"San Francisco", "state":"CA", "postal_code":"94111", "country": "US" } } }
You can simply make an object of json.您可以简单地制作一个 json 的 object。
like像
var obj = { "name": "kiran", "email": "sai123@gmail.com", "phone_number": "123456789", "type": "individual", "billing": { "address":{ "line1":"1234 Main Street", "city":"San Francisco", "state":"CA", "postal_code":"94111", "country": "US" } } }
Then然后
Post(obj:any) {
return this.http.post('apiUrlhere',{obj});
}
and call it using并使用
this.Post(ObjHere)
.subscribe(
data => {
//result inside data
});
private http: HttpClient
私人 http:HttpClient
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.