i'm trying to do a POST request with an API taking a specific format of variable. But I can't figure out what the format of this is?
The full request payload is
csrfmiddlewaretoken=XXXXXXXXX&username=Test&first_name=Test1&last_name=Test2&[email protected]&password1=Testtest24&password2=Testtest24
My goal is to be able to make a variable with the same format in angular.
CodePudding user response:
This is the application/x-www-form-urlencoded
format, i.e. the same format browsers use to encode data of plain HTML forms sent to a server.
Data in this format can usually be used either by appending it to a GET request as e.g. https://example.com?foo=bar&alice=bob or within the body of a POST request with the correct Content-Type
header.
When sending a request in Angular, you generally do not have to deal with this encoding as Angular itself will take care of properly encoding it before sending the data to the server.