Multiple Objects into HttpParams

后端 未结 3 1784
孤街浪徒
孤街浪徒 2021-02-08 07:00

I have some categories in a formcontrol, I send them in an array of string like this:

[1,4,6]

And that is my actual code:



        
3条回答
  •  一整个雨季
    2021-02-08 07:39

    You can create object containing all parameters and pass this object to fromObject property of HttpParamOptons while creating HttpParams

    let data={
       firstname:'xyz',
       lastname:'pqr'
    }
    
    let body=new HttpParams({fromObject:data})
    
    this.http.post(URL, body, this.header).subscribe(data => {
     ....
    }, error => {
     ....
    })
    

提交回复
热议问题