Answer the question
In order to leave comments, you need to log in
How to correctly set body in POST request, angular 6?
Of course, I understand that it's done like this: http.post(url, body);
body is an object with key:value pairs.
Here it is not clear to me how it comes to the server. How is the object?
In this case, you can't just take and make $_POST['email'] on the server, right?
The object comes. How can I form a request that will be convenient $_POST "it?
After all, if I use a non-angular form. The request comes like this:
In this case, everything works. {email: '[email protected]', password: 'pw'}
username=mail%mail.com&password=pw
Answer the question
In order to leave comments, you need to log in
If anyone needs it, this header helped:
private options = {
headers: new HttpHeaders({ 'Content-Type': 'application/x-www-form-urlencoded' })
};
...
this.http.post( url, body, options);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question