The GET API function gets a complete list of users.
In order to get the complete user list from the MongoDB database, we will rewrite the list_users() function as follows:
def list_users(): api_list=[] db = connection.cloud_native.users for row in db.find(): api_list.append(str(row)) return jsonify({'user_list': api_list})
Let's test it on POSTMAN and see if the API responds as expected:
Since we currently have only one document in the user's collection of the MongoDB database, you can see only one user in the users list in the preceding screenshot.