March 2020
Intermediate to advanced
392 pages
10h 10m
English
Updating the address is fairly similar to how we updated the user. The main difference is that we are saving a model that is connected to the user.
Go through the following steps:
let content = try request.content.decode(AddressInput.self)
let id = try request.query.get(Int.self)
This ID is of type Int (not optional), and it has to be present. If the requester tries to send something other than Int, the Router will reject the call.
Next, we need to find the correct address in the database. We know the ID of the address, and we know the user ID of the user who owns this address. So, we will simply make both conditions for ...
Read now
Unlock full access