简体   繁体   中英

Http post request by passing query params in angular 8

How to send requested parameters as a query params.

I tried like

addLocal(data: any) {
   const queryParams = `?email=${data.email}&name=${data.name}&phone_number=${data.phone_number}`;
   return this.httpclient.post('https://www.example.com/coming/receive' + queryParams);
}

But with this getting error accepted arguments 2-3.

How to call such requests

With json i used like below, but for passing data as query?

addLocal(data: any) {
    return this.httpclient.post('https://www.example.com/coming/receive', data);
}

Try using like this,

 return this.httpclient.post('https://www.example.com/coming/receive' + queryParams,{});

EDIT:

Http POST takes resource URL as a parameter and additional two paramters

  • Data to POST in the body of the request
  • Method HttpOptions (if any and is optional ex. header information).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM