0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 8
click for more info
No active XP Potion
Accept a Quest
Login to submit answers
Now we need a way to lookup a single chirp by its ID. You might be thinking:
"If I can get all of the chirps, why do I need a way to get just one?"
Imagine there are 10,000 chirps in the database - no, imagine 10,000,000,000! We'll obviously need to change our GET /api/chirps
endpoint to only return a subset of chirps at a time.
However, our users will still need a way to view a single chirp - for example, maybe they have a link directly to it.
GET /api/chirps/94b7e44c-3604-42e3-bef7-ebfcc3efff8f
You can get the string value of the path parameter like in Go with the http.Request.PathValue
method.
{
"id": "94b7e44c-3604-42e3-bef7-ebfcc3efff8f",
"created_at": "2021-01-01T00:00:00Z",
"updated_at": "2021-01-01T00:00:00Z",
"body": "fr? no clowning?",
"user_id": "123e4567-e89b-12d3-a456-426614174000"
}
Run and submit the CLI tests.
The Boot.dev CLI requires you to be signed in to submit your solution!
Copy/paste one of the following commands into your terminal:
Run
bootdev run 0a07a4a3-c11f-429f-ac70-52fa2e016bc0
Submit
bootdev run 0a07a4a3-c11f-429f-ac70-52fa2e016bc0 -s
To run and submit the tests for this lesson, you must have an active Boot.dev membership
Become a member to view solution
Using the Bootdev CLI
The Bootdev CLI is the only way to submit your solution for this type of lesson. We need to be able to run commands in your environment to verify your solution.
You can install it here. It's a Go program hosted on GitHub, so you'll need Go installed as well. Instructions are on the GitHub page.