I sow a lot of examples where developers have the following expression:
return jsonify(data), 200
Even in my last work project I had the same expression, but now, when I'm trying to write my new project, I catch the following error:
TypeError: Object of type Response is not JSON serializable
If I return only the result of jsonify()
, it works but returns the 200 status code. I want to control the code. It doesn't work with flask_restful.Resource
.
Seems like jsonify()
returns Response
object. How to fix it?
flask-restful uses jsonify already.
if you use jsonify with flask-restful, it tries to jsonify a response twice.
simply do this: