Recipe 15 | Making GET Requests |
Task
Your team is using GitHub for hosting your code. As part of an effort to improve the development process, you are asked to provide some metrics on the project. Your first task is to list the currently open pull requests (PRs).
After spending some time reading the GitHub API with documentation, you find out that you need to:
- Construct a URL in the format /repos/{owner}/{repo}/pulls
- Set the Content-Type header to application/vnd.github.v3+json
- Pass state=open as an HTTP query parameter
The response is a JSON document in the following format:
| [ |
| { |
| "number": 138, |
| "state": "open", |
| "title": "Add option to filter by date", |
| ... |
| }, |
| { |
| "number": 297, |
| "state": ... |
Get Effective Go Recipes now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.