Getting CSV file from private repo in Github

Sup @nyc-tinker. Here’s an example for you:

You may have also seen this notebook? Maybe that’s where you saw the undefined && Secret("GITHUB_ACCESS_TOKEN") thing. I actually just edited it to simplify it a little.

Previously (you can see the old version here) it imported from this other notebook which has a fetchGithub function, which calls fetchGithubResponse, which calls fetch and passes in headers including the Secret.

In the simplified version, I just include the fetchGithub function in the notebook. You can see how it passes the Secret in: we pass

authorization: `token ${Secret("GITHUB_ACCESS_TOKEN")}`

in the headers of the fetch request. (fetch is the browser-standard function that d3.csv uses behind-the-scenes.) That notebook assumes the response is JSON, so my example for you builds on that to fetch a CSV.

1 Like