// Create a personal access token at https://github.com/settings/tokens/new?scopes=repo const octokit = newOctokit({ auth: `personal-access-token123` });
await octokit.rest.issues.create({ owner: "octocat", repo: "hello-world", title: "Hello, world!", body: "I created this issue using Octokit!", });
和下面的方式相同
1 2 3 4 5 6
await octokit.request("POST /repos/{owner}/{repo}/issues", { owner: "octocat", repo: "hello-world", title: "Hello, world!", body: "I created this issue using Octokit!", });
try { // your code here that sends at least one Octokit request await octokit.request("GET /"); } catch (error) { // Octokit errors are instances of RequestError, so they always have an `error.status` property containing the HTTP response code. if (error instanceofRequestError) { // handle Octokit error // error.message; // Oops // error.status; // 500 // error.request; // { method, url, headers, body } // error.response; // { url, status, headers, data } } else { // handle all other errors throw error; } }