I\'m creating a frontend in Angular, and the backend in Flask with the RESTful extension. By default, Angular likes to send data back as a payload (eg this is what it appear
You will, I think, need to do the following:
(1) Make location='json'
explicit in add_argument
:
self.parser.add_argument('user', type=str, location='json', required=True)
self.parser.add_argument('passw', type=str, location='json', required=True)
(2) Ensure the header field Content-Type
of the http request from the client is application/json
(3) The request payload should look like this:
{
"user": "abc",
"passw": "123456"
}
I routinely parse JSON requests with flask-restful without any trouble. One small difference is that I don't have my request parser as an instance field of the resource. Not sure if that is causing you trouble, but it might be worth a try to move it out if you are still stuck.