Answer the question
In order to leave comments, you need to log in
How to pass post parameters to http.client Angular?
What could be the reason why angular httpClient doesn't send post parameters?
At once I will tell - I read the documentation.
The server in php and when tested via Postman and debugging tools accepts post parameters.
I even made the output of all post parameters, but for some reason, Angular does not send them.
public urlapi = 'http://localhost:81/';
private httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json'
})
};
public GetOrders(): Observable<[]>{
const postBody = {'param': 'value'};
return this.http.post(this.urlapi, postBody , this.httpOptions)
.pipe(map(data => {
return data.map((element: any) => {
return {id: element.Id};
});
}));
Answer the question
In order to leave comments, you need to log in
It's weird, but it worked
const formData = new FormData();
formData.append('picture', file);
formData.append('OrderId', this.ordersService.SelectedOrder['Id']);
return this.http.post(this.urlapi, formData , this.httpOptions)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question