HTTP Post with no body in Angular HTTP Post with no body in Angular typescript typescript

HTTP Post with no body in Angular


Looks like this is the appropriate answer:

postRequest(id) {  this.http.post('/api?data=' + id, null).map(    (response) => {      return response;    }  )}


If null is not working (4XX error client side), try with {} JSON:

postRequest(id) {    this.http.post('/api?data=' + id, {}).map((response) => {return response;});}


Go to definition of POST method using your IDE and you can see passing either body: any | null are the available inputs

post(url: string, body: any | null, options: {    headers?: HttpHeaders | {        [header: string]: string | string[];    };