Skip to content

How can I user the rest api to get a named repo for the authenticated user? #2483

Closed Answered by gr2m
Mufasa asked this question in General
Discussion options

You must be logged in to vote
const { data: repository}  = await octokit.rest.repos.get({owner: "octokit", repo: "octokit.js"})

If you want to get the current user's username, you can do

const { data: user } = await octokit.rest.users.getAuthenticated()
// user.login

Also, is there a way to get the commit details given its commit SHA (again for a non-organisational repo)?

It's the same for user and org repositories

const { data: commit } = await octokit.rest.repos.getCommit({ owner: "octokit", repo: "octokit.js", ref: "46b5f2fd41ef6d2ac23653ca302d6ba7e5559c02" })

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@Mufasa
Comment options

@gr2m
Comment options

gr2m Jun 21, 2023
Maintainer

@Mufasa
Comment options

@Mufasa
Comment options

@gr2m
Comment options

gr2m Jun 21, 2023
Maintainer

Answer selected by gr2m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants