How do I get the result of octokit.issues.listComments as a stream? #2724
Unanswered
AleksandrHovhannisyan
asked this question in
Q&A
Replies: 1 comment 1 reply
-
You are sending the wrong header. Remove the custom accept header and your request should work |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello! For a while now, I've been using the GitHub Issues API as a makeshift comment system for my personal website. I open one issue per article that I've written, and users can leave comments that my page then queries for. My server-side code uses the Octokit SDK to make authenticated requests to the API:
https://github.com/AleksandrHovhannisyan/aleksandrhovhannisyan.com/blob/34ebe5a22114937b21916737125cf65fb2d67554/api/comments.js#L43-L54
Unfortunately, this tends to be a bit slow when I need to fetch lots of comments. I'm new to HTTP streaming as a concept but I read that it could help me with this problem, so that instead of buffering all the responses and sending them in one go, my server could stream the results to the client one by one as they arrive. At least that's my tenuous understanding.
I did a bit of research and found this thread on the
octokit/request.js
repo: [FEAT]: Allow streaming of the data. In that thread, it is suggested that support was added to stream data from Octokit endpoints. One of the code samples referenced in that issue is this code for streaming assets:So I updated my code to include the
headers
andrequest
objects:Unfortunately, when I do that, I get the following error upon making a request:
Does this mean that streaming is not supported for the
listComments
API?Environment:
@octokit/auth-token: 5.1.1
@octokit/core: 6.1.2
@octokit/rest: 21.0.1
Beta Was this translation helpful? Give feedback.
All reactions