You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GitHub Issue: Fetch Placeholder Data from External API
Task
Create an endpoint /fetch-post/{post_id} that fetches a post from the JSONPlaceholder API and returns the data.
Requirements
Use httpx to fetch data from JSONPlaceholder.
Accept a post_id parameter in the request URL.
Extract and return the following fields:
Title
Body
Handle errors if the post ID is invalid.
Acceptance Criteria
✅ Fetch data successfully and return:
json
Copy
Edit
{
"title": "Sample Post Title",
"body": "This is the content of the post."
}
✅ Handle invalid post IDs by returning a 404 Not Found error.
API Endpoint to Use
arduino
Copy
Edit https://jsonplaceholder.typicode.com/posts/{post_id}
Additional Notes
Ensure proper exception handling in case of API failures.
Use FastAPI’s HTTPException for error responses.
Would you like the solution code as well?
The text was updated successfully, but these errors were encountered:
GitHub Issue: Fetch Placeholder Data from External API
Task
Create an endpoint /fetch-post/{post_id} that fetches a post from the JSONPlaceholder API and returns the data.
Requirements
Use httpx to fetch data from JSONPlaceholder.
Accept a post_id parameter in the request URL.
Extract and return the following fields:
Title
Body
Handle errors if the post ID is invalid.
Acceptance Criteria
✅ Fetch data successfully and return:
json
Copy
Edit
{
"title": "Sample Post Title",
"body": "This is the content of the post."
}
✅ Handle invalid post IDs by returning a 404 Not Found error.
API Endpoint to Use
arduino
Copy
Edit
https://jsonplaceholder.typicode.com/posts/{post_id}
Additional Notes
Ensure proper exception handling in case of API failures.
Use FastAPI’s HTTPException for error responses.
Would you like the solution code as well?
The text was updated successfully, but these errors were encountered: