I'm setting up MongoDB for my Python app, and have this code:
@app.route('/user/<firstName>', methods=['GET'])
def getUser(firstName):
print(firstName)
return jsonify({'users': Users.find({'first_name': firstName})[0]})
which throws this error: TypeError: Object of type ObjectId is not JSON serializable
due to the _id
field being '_id': ObjectId('5e8676dc0d16f3567167d889').
How do I get around this?