簡體   English   中英

如何在 angular 的 post 請求中發送這種類型的正文

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM