Type Error: The return type must be a string, dict, tuple, Response instance, or WSGI callable, but it was a list Type Error: The return type must be a string, dict, tuple, Response instance, or WSGI callable, but it was a list flask flask

Type Error: The return type must be a string, dict, tuple, Response instance, or WSGI callable, but it was a list


User oz19 commented

You need to serialize objects before returning. import json and then json.dumps(objects)

and also

You have a return(objects) at the end of for c in cnts. That could be the problem

So the solution if, not using jsonify, is to call json.dumps on the list before returning it.


The views in Flask require a hashable return type. You can always convert your return values to hashable types viz string, dict, tuple etc and then transform from the result.

return { "data": [ { "name": "my name", age: "27" } ] }