[英]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" } } }
您可以簡單地制作一個 json 的 object。
像
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" } } }
然后
Post(obj:any) {
return this.http.post('apiUrlhere',{obj});
}
並使用
this.Post(ObjHere)
.subscribe(
data => {
//result inside data
});
其中http是
私人 http:HttpClient
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.