I'm using Octokit/rest js to fetch pull requests from a repository.
Ideally, I'd like to have pull requests from x date to y date depending on the creation date.
Is there a way to do this?
Right now I'm fetching all the pull requests and then iterating over them.
Ideally, I would like to passe some parameters on the request. This is what I'm doing now:
const pullRequests = await octokit.paginate(
'/repos/{owner}/{repo}/pulls',
{
owner: organization.providerLogin,
repo: repository.name,
state: 'all',
},
This is what I would like to do:
const pullRequests = await octokit.paginate(
'/repos/{owner}/{repo}/pulls?q=createdat2022-04-01..2022-04-07',
{
owner: organization.providerLogin,
repo: repository.name,
state: 'all',
},
I would use
@octokit/rest
for this job with GitHub's Search API.I created a RunKit where you can play with: https://runkit.com/dominguezcelada/625035fc20b0c4000842fde9
You can wrap the previous code snippet with
octokit.paginate()
to get all the paginated results.Let me know if this works or not. I would be happy to help you on that if necessary.