GET api/v1/users/[user_id]

This API function gets the details of a specific user.

In order to list the details of a specific user from the MongoDB database, use the modify list_user(user_id) function as follows:

    def list_user(user_id): 
     api_list=[] 
     db = connection.cloud_native.users 
     for i in db.find({'id':user_id}): 
       api_list.append(str(i)) 
 
     if api_list == []: 
       abort(404) 
     return jsonify({'user_details':api_list} 

Let's test it on POSTMAN to see if it works as expected:

Also, we need to test the scenario where a user entry is not present; try this out, as shown in the following code:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.131.152.166