Getting one user by ID

Find the code snippet getAllUserByID() operation as follows:

 // to get one specific user details
@GetMapping("/user/{id}")
fun getUser(@PathVariable(name = "id") id: Long): UserModel {
return userRepository.findById(id).get()
}

The @GetMapping(path = ["/user/{id}"]) annotation is the URL path of "/user/{id}", and it is a  GET request with a specific ID. Here, we return findById(id).get() to get the specific user details from the database.

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

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