Retrieve one individual entry
Last updated
Last updated
We need to define a PATH PARAMETER
in the decorator
We can then pass the path parameter to the function directly
This will allow us send the HTTP Request and retrieve some info
Note: We have a hardcoded post with ID 2
A better way of doing this (but not best practice) would be to create a function which retrieves the posts
Then use the PATH PARAMETER
as the ID for our function
Full code:
Send the HTTP request to test the results
There is a problem with this approach. If you provide a string that cannot be converted to an integer, it will throw an INTERNAL SERVER ERROR
response
We need to perform some kind of validation to ensure that whatever data is being passed to this parameter can be converted properly into an integer
This can be done directly via FastAPI
Now we can send the HTTP Request
And get proper feedback of what went wrong