### Install Dependencies and Start Docs Server Source: https://github.com/octokit/rest.js/blob/main/docs/README.md Run these commands to install project dependencies, navigate to the docs directory, install its dependencies, and start the local development server for the documentation website. ```bash npm install cd /docs npm install npm start ``` -------------------------------- ### Installation and Instantiation Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/00_usage.md Install the @octokit/rest library using npm and instantiate the Octokit client. Authentication is recommended. ```APIDOC ## Installation Install with `npm install @octokit/rest` ## Instantiation ```js import { Octokit } from "@octokit/rest"; const octokit = new Octokit({ // Optional: Authentication token auth: "YOUR_PERSONAL_ACCESS_TOKEN", // Required: User agent to identify your application userAgent: "myApp v1.0.0", // Optional: Enable API previews previews: ["jean-grey", "symmetra"], // Optional: Set a default time zone timeZone: "Europe/Amsterdam", // Optional: For GitHub Enterprise baseUrl: "https://api.github.com", // Optional: Custom logging log: { debug: () => {}, info: () => {}, warn: console.warn, error: console.error }, // Optional: Custom request options request: { agent: undefined, fetch: undefined, timeout: 0 } }); ``` ``` -------------------------------- ### Setup Octokit with Retry Plugin Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/10_retries.md Install the @octokit/plugin-retry plugin to enable automatic retries for recoverable errors. Requests will be retried up to 3 times. ```javascript import { Octokit } from "@octokit/rest"; import { retry } from "@octokit/plugin-retry"; const MyOctokit = Octokit.plugin(retry); const octokit = new MyOctokit(); // all requests sent with the `octokit` instance are now retried up to 3 times for recoverable errors. ``` -------------------------------- ### Start Fixtures Server Source: https://github.com/octokit/rest.js/blob/main/CONTRIBUTING.md Run this command to start the fixtures server before running tests. Ensure you have the fixtures server running in a separate terminal. ```bash $ npm run start-fixtures-server ``` -------------------------------- ### Verify Local Installation Source: https://github.com/octokit/rest.js/blob/main/CONTRIBUTING.md After installing a pull request locally, use this command to verify the installation and check the version details. ```text └── @octokit/rest@0.0.0-development (git+https://github.com/octokit/rest.js.git#505ed1f57671480b625131abb00c277c67cae40a) ``` -------------------------------- ### Enable Console Logging for Octokit.js Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/12_debug.md Set the `log` client option to `console` to receive detailed debug information about requests. This is the simplest way to get started with debugging. ```javascript import { Octokit } from "@octokit/rest"; const octokit = new Octokit({ log: console, }); octokit.request("/"); ``` -------------------------------- ### Run All Tests Source: https://github.com/octokit/rest.js/blob/main/CONTRIBUTING.md Execute all tests for the project. This command should be run after starting the fixtures server. ```bash $ npm test ``` -------------------------------- ### Pagination Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/00_usage.md Example of how to paginate through API responses that return a list of items. ```APIDOC ## Pagination ```js (async () => { octokit.paginate(octokit.rest.issues.listForRepo, { owner: 'octokit', repo: 'rest.js' }) .then(issues => { // issues is an array of all issue objects }); })(); ``` ``` -------------------------------- ### Import Octokit for Node.js Source: https://github.com/octokit/rest.js/blob/main/README.md Install @octokit/rest using npm and import Octokit for use in Node.js applications. ```javascript import { Octokit } from "@octokit/rest"; ``` -------------------------------- ### Making API Requests Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/00_usage.md Examples of how to make various API requests, including retrieving a pull request, handling different media types, and making custom requests. ```APIDOC ## Retrieving a Pull Request ```js (async () => { const { data: pullRequest } = await octokit.rest.pulls.get({ owner: "octokit", repo: "rest.js", pull_number: 123, }); })(); ``` ## Requesting Different Media Types (e.g., Diff Format) ```js (async () => { const { data: diff } = await octokit.rest.pulls.get({ owner: "octokit", repo: "rest.js", pull_number: 123, mediaType: { format: "diff", }, }); })(); ``` ## Making Custom Requests (e.g., Root Endpoint) ```js (async () => { const { data: root } = await octokit.request("GET /"); })(); ``` ``` -------------------------------- ### Send a Custom GET Request Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/04_custom_requests.md Use `octokit.request()` to send a custom GET request. The `baseUrl`, headers, and other defaults are pre-configured. ```javascript octokit.request("GET /"); ``` -------------------------------- ### Configure Throttling Plugin Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/00_usage.md Configure the throttling plugin when instantiating a plugin-enabled Octokit client. This example shows how to handle rate limits by retrying once. ```javascript const myOctokit = new MyOctokit({ auth: "secret123", throttle: { onRateLimit: (retryAfter, options) => { myOctokit.log.warn( `Request quota exhausted for request ${options.method} ${options.url}`, ); if (options.request.retryCount === 0) { // only retries once myOctokit.log.info(`Retrying after ${retryAfter} seconds!`); return true; } }, }, }); ``` -------------------------------- ### Install Pull Request Locally Source: https://github.com/octokit/rest.js/blob/main/CONTRIBUTING.md Install a specific pull request from GitHub locally to test changes before merging. Replace 'branchname' with the actual branch name of the pull request. ```bash npm install octokit/rest.js#branchname ``` -------------------------------- ### Handle Secondary Rate Limits in Octokit Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/00_usage.md Implement a custom handler for secondary rate limits. This example logs a warning but does not automatically retry the request. ```javascript onSecondaryRateLimit: (retryAfter, options, octokit) => { // does not retry, only logs a warning octokit.log.warn( `Secondary quota detected for request ${options.method} ${options.url}`, ); }, ``` -------------------------------- ### Configure Octokit with Throttling Plugin Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/09_throttling.md Install and configure the @octokit/plugin-throttling to automatically retry requests when rate limits are hit. The `onRateLimit` function can be configured to retry a specified number of times. ```javascript import { Octokit } from "@octokit/rest"; import { throttling } from "@octokit/plugin-throttling"; const MyOctokit = Octokit.plugin(throttling); const octokit = new MyOctokit({ auth: "token " + process.env.TOKEN, throttle: { onRateLimit: (retryAfter, options) => { octokit.log.warn( `Request quota exhausted for request ${options.method} ${options.url}`, ); // Retry twice after hitting a rate limit error, then give up if (options.request.retryCount <= 2) { console.log(`Retrying after ${retryAfter} seconds!`); return true; } }, onSecondaryRateLimit: (retryAfter, options, octokit) => { // does not retry, only logs a warning octokit.log.warn( `Secondary quota detected for request ${options.method} ${options.url}`, ); }, }, }); ``` -------------------------------- ### Retrieve Default Request Options Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/04_custom_requests.md Get the default options for a specific endpoint method, such as `octokit.rest.repos.get()`. Note that authentication is not applied to these options. ```javascript const defaultOptions = octokit.rest.repos.get.endpoint.DEFAULTS; ``` ```javascript const requestOptions = octokit.rest.repos.get.endpoint({ owner: "octokit", repo: "rest.js", }); ``` -------------------------------- ### Revert to Default Module Source: https://github.com/octokit/rest.js/blob/main/CONTRIBUTING.md After testing a pull request, use this command to revert back to the default stable version of the @octokit/rest module installed from npm. ```bash npm install @octokit/rest ``` -------------------------------- ### Register Custom Endpoint Methods Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/00_usage.md Register custom endpoint methods for private betas or specific needs. Define the method (e.g., 'GET') and the URL. ```javascript await octokit.registerEndpoints({ misc: { getRoot: { method: "GET", url: "/", }, }, }); ``` -------------------------------- ### Register error hook for requests Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/06_hooks.md Use `octokit.hook.error` to catch and handle errors during requests. This example shows how to handle 304 Not Modified responses by returning cached data. ```javascript octokit.hook.error("request", async (error, options) => { if (error.status === 304) { return findInCache(error.response.headers.etag); } throw error; }); ``` -------------------------------- ### Instantiate Octokit with Options Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/00_usage.md Instantiate the Octokit client with various configuration options. Authentication is strongly recommended. ```javascript const octokit = new Octokit({ auth: "secret123", userAgent: 'myApp v1.2.3', previews: ['jean-grey', 'symmetra'], timeZone: 'Europe/Amsterdam', baseUrl: 'https://api.github.com', log: { debug: () => {}, info: () => {}, warn: console.warn, error: console.error }, request: { agent: undefined, fetch: undefined, timeout: 0 } }) ``` -------------------------------- ### Initialize Octokit and List Organization Repositories Source: https://github.com/octokit/rest.js/blob/main/README.md Instantiate the Octokit client and make a request to list public repositories for a given organization. Ensure your tsconfig.json is configured for module resolution if using TypeScript. ```javascript const octokit = new Octokit(); // Compare: https://docs.github.com/en/rest/reference/repos/#list-organization-repositories octokit.rest.repos .listForOrg({ org: "octokit", type: "public", }) .then(({ data }) => { // handle data }); ``` -------------------------------- ### Using Plugins (Retry and Throttling) Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/00_usage.md Demonstrates how to extend Octokit's functionality by adding plugins like retry and throttling. ```APIDOC ## Plugins ```js import { retry } from "@octokit/plugin-retry"; import { throttling } from "@octokit/plugin-throttling"; const MyOctokit = Octokit.plugin(retry, throttling); const myOctokit = new MyOctokit({ auth: "secret123", throttle: { onRateLimit: (retryAfter, options) => { myOctokit.log.warn( `Request quota exhausted for request ${options.method} ${options.url}`, ); if (options.request.retryCount === 0) { // only retries once myOctokit.log.info(`Retrying after ${retryAfter} seconds!`); return true; } }, }, }); ``` ``` -------------------------------- ### Instantiate Octokit with Plugin and Call Custom Method Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/08_plugins.md Instantiate Octokit with your custom plugin, passing any necessary options. You can then call the custom methods added by your plugin, such as `helloWorld()`. ```javascript const octokit = new MyOctokit({ greeting: "Hola" }); octokit.helloWorld(); // Hola, world! ``` -------------------------------- ### Import Octokit for Browsers (esm.sh) Source: https://github.com/octokit/rest.js/blob/main/README.md Load @octokit/rest directly from esm.sh for use in web browsers. ```html ``` -------------------------------- ### Load Plugins for Octokit Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/00_usage.md Extend Octokit's functionality by loading plugins like retry and throttling. This creates a new constructor that includes the plugin's capabilities. ```javascript import { retry } from "@octokit/plugin-retry"; import { throttling } from "@octokit/plugin-throttling"; const MyOctokit = Octokit.plugin(retry, throttling); ``` -------------------------------- ### Register before hook for requests Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/06_hooks.md Use `octokit.hook.before` to execute custom logic before each request is sent. Ensure any necessary validation functions are available. ```javascript octokit.hook.before("request", async (options) => { validate(options); }); ``` -------------------------------- ### List Organization Repositories with Octokit Source: https://github.com/octokit/rest.js/blob/main/HOW_IT_WORKS.md Use this method to retrieve all public repositories for a given GitHub organization. Ensure the organization name is correctly provided. ```javascript octokit.rest.repos.listForOrg({ org: "octokit", type: "public" }); ``` -------------------------------- ### Authenticate with GitHub App Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/01_authentication.md Configure Octokit to authenticate as a GitHub App using `createAppAuth`. This requires `appId`, `privateKey`, and optionally `installationId`. ```javascript import { Octokit } from "@octokit/rest"; import { createAppAuth } from "@octokit/auth-app"; const appOctokit = new Octokit({ authStrategy: createAppAuth, auth: { appId: 123, privateKey: process.env.PRIVATE_KEY, // optional: this will make appOctokit authenticate as app (JWT) // or installation (access token), depending on the request URL installationId: 123, }, }); const { data } = await appOctokit.request("/app"); ``` -------------------------------- ### Octokit Logging Methods Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/11_logging.md Octokit provides four built-in methods for logging: debug, info, warn, and error. These methods can be configured via the 'log' client option. By default, debug and info are no-ops, while warn and error call console.warn and console.error respectively. ```APIDOC ## Octokit Logging Methods ### Description Provides four built-in methods for logging messages and additional information. ### Methods - `octokit.log.debug(message[, additionalInfo])` - `octokit.log.info(message[, additionalInfo])` - `octokit.log.warn(message[, additionalInfo])` - `octokit.log.error(message[, additionalInfo])` ### Configuration Logging can be configured using the `log` client option. By default: - `octokit.log.debug()` and `octokit.log.info()` are no-ops. - `octokit.log.warn()` calls `console.warn()`. - `octokit.log.error()` calls `console.error()`. ### Usage Example ```javascript const octokit = new Octokit({ // Configuration options log: { debug: (msg) => console.log('DEBUG:', msg), info: (msg) => console.log('INFO:', msg), warn: (msg) => console.warn('WARN:', msg), error: (msg) => console.error('ERROR:', msg) } }); octokit.log.debug('This is a debug message'); octokit.log.info('This is an info message'); octokit.log.warn('This is a warning message'); octokit.log.error('This is an error message'); ``` ``` -------------------------------- ### Octokit Logging Methods Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/11_logging.md Octokit provides four built-in logging methods: debug, info, warn, and error. These can be configured using the 'log' client option. By default, debug and info are no-ops. ```javascript octokit.log.debug(message[, additionalInfo]) ``` ```javascript octokit.log.info(message[, additionalInfo]) ``` ```javascript octokit.log.warn(message[, additionalInfo]) ``` ```javascript octokit.log.error(message[, additionalInfo]) ``` -------------------------------- ### Paginate and map results with octokit.paginate() Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/05_pagination.md Pass a mapping function to `octokit.paginate()` to transform the data from each response. The map function receives the full response object and should return the desired mapped data. ```javascript octokit .paginate( "GET /repos/{owner}/{repo}/issues", { owner: "octokit", repo: "rest.js" }, (response) => response.data.map((issue) => issue.title), ) .then((issueTitles) => { // issueTitles is now an array with the titles only }); ``` -------------------------------- ### Authenticate with Personal Access Token Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/01_authentication.md Use a personal access token for authentication. The `Authorization` header will be set to `token YOUR_TOKEN`. ```javascript import { Octokit } from "@octokit/rest"; const octokit = new Octokit({ auth: "mypersonalaccesstoken123", }); // sends request with `Authorization: token mypersonalaccesstoken123` header const { data } = await octokit.request("/user"); ``` -------------------------------- ### Define and Register Octokit Plugin Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/08_plugins.md Import and register custom plugins with Octokit. The `.plugin` method accepts one or more plugin functions. Ensure your plugin function correctly hooks into Octokit's lifecycle or adds new methods. ```javascript import { Octokit } from "@octokit/rest"; import myPlugin from "./lib/my-plugin.js"; import octokitPluginExample from "octokit-plugin-example"; const MyOctokit = Octokit.plugin(myPlugin, octokitPluginExample); ``` ```javascript const plugin = (octokit, options = { greeting: "Hello" }) => { // hook into the request lifecycle octokit.hook.wrap("request", async (request, options) => { const time = Date.now(); const response = await request(options); octokit.log.info( `${options.method} ${options.url} – ${response.status} in ${ Date.now() - time }ms`, ); return response; }); // add a custom method: octokit.helloWorld() return { helloWorld: () => console.log(`${options.greeting}, world!`), }; }; export default plugin; ``` -------------------------------- ### Iterate through paginated responses with async iterators Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/05_pagination.md If your environment supports async iterators, use `octokit.paginate.iterator()` to loop through each paginated response. This allows for processing responses individually as they arrive. ```javascript for await (const response of octokit.paginate.iterator( octokit.rest.issues.listForRepo, { owner: "octokit", repo: "rest.js", }, )) { // do whatever you want with each response, break out of the loop, etc. } ``` -------------------------------- ### Register after hook for requests Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/06_hooks.md Use `octokit.hook.after` to run code after a request completes successfully. This hook receives the response and original request options. ```javascript octokit.hook.after("request", async (response, options) => { console.log(`${options.method} ${options.url}: ${response.status}`); }); ``` -------------------------------- ### Run Specific Test Source: https://github.com/octokit/rest.js/blob/main/CONTRIBUTING.md Execute a specific test file. This is useful for debugging or focusing on a particular test case. ```bash $ ./node_modules/.bin/jest test/integration/smoke.test.js ``` -------------------------------- ### Paginate all results with octokit.paginate() Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/05_pagination.md Use `octokit.paginate()` to automatically fetch all items across paginated API responses. This method returns a flat array of all results, not wrapped in a response object. ```javascript octokit .paginate("GET /repos/{owner}/{repo}/issues", { owner: "octokit", repo: "rest.js", }) .then((issues) => { // issues is an array of all issue objects. It is not wrapped in a { data, headers, status, url } object // like results from `octokit.request()` or any of the endpoint methods such as `octokit.rest.issues.listForRepo()` }); ``` -------------------------------- ### Registering Request Hooks in Octokit.js Source: https://github.com/octokit/rest.js/blob/main/HOW_IT_WORKS.md Use `octokit.hook.before` to execute code before a request is sent, `octokit.hook.after` to execute code after a response is received, `octokit.hook.error` to handle request errors, and `octokit.hook.wrap` to fully customize the request lifecycle. Callbacks can be asynchronous. ```javascript octokit.hook.before("request", async (options) => { validate(options); }); ``` ```javascript octokit.hook.after("request", async (response, options) => { console.log(`${options.method} ${options.url}: ${response.status}`); }); ``` ```javascript octokit.hook.error("request", async (error, options) => { if (error.status === 304) { return findInCache(error.response.headers.etag); } throw error; }); ``` ```javascript octokit.hook.wrap("request", async (request, options) => {}); ``` -------------------------------- ### Make a Custom Request Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/00_usage.md Use `octokit.request()` for API endpoints that do not have a direct method, such as the root endpoint or legacy endpoints. The method and URL are required. ```javascript const { data: root } = await octokit.request("GET /"); ``` -------------------------------- ### Configure Log Level with console-log-level Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/12_debug.md Use the `console-log-level` module to configure a specific log level, such as 'info', for Octokit.js requests. This helps filter out less important debug messages. ```javascript import { Octokit } from "@octokit/rest"; import consoleLogLevel from "console-log-level"; const octokit = new Octokit({ log: consoleLogLevel({ level: "info" }), }); octokit.request("/"); ``` -------------------------------- ### Register and use a custom endpoint method Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/07_custom_endpoints.md Extend the octokit object to register custom endpoint methods. This is useful for private beta features where you prefer method convenience over `octokit.request()`. ```javascript Object.assign(octokit.foo, { bar: { method: "PATCH", url: "/repos/{owner}/{repo}/foo", headers: { accept: "application/vnd.github.foo-bar-preview+json", }, params: { owner: { required: true, type: "string", }, repo: { required: true, type: "string", }, baz: { required: true, type: "string", enum: ["qux", "quux", "quuz"], }, }, }, }); octokit.foo.bar({ owner: "octokit", repo: "rest.js", baz: "quz", }); ``` -------------------------------- ### Register wrap hook for requests Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/06_hooks.md Use `octokit.hook.wrap` to completely replace the request logic. This allows for pre-processing, post-processing, error handling, or entirely custom request implementations. ```javascript octokit.hook.wrap("request", async (request, options) => { // add logic before, after, catch errors or replace the request altogether return request(options); }); ``` -------------------------------- ### Paginate registered endpoint methods with octokit.paginate() Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/05_pagination.md You can pass registered endpoint methods, like `octokit.rest.issues.listForRepo`, directly as the first argument to `octokit.paginate()` to paginate their results. ```javascript octokit .paginate(octokit.rest.issues.listForRepo, { owner: "octokit", repo: "rest.js", }) .then((issues) => { // issues is an array of all issue objects }); ``` -------------------------------- ### Paginate API Results Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/00_usage.md Use `octokit.paginate()` to retrieve all items from paginated API responses, such as listing issues for a repository. This simplifies handling multiple pages of results. ```javascript octokit.paginate(octokit.rest.issues.listForRepo, { owner: 'octokit', repo: 'rest.js' }) .then(issues => { // issues is an array of all issue objects }) ``` -------------------------------- ### Registering Custom Endpoint Methods Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/00_usage.md How to register custom endpoint methods for endpoints that may not have a direct match in the library, such as legacy or private beta endpoints. ```APIDOC ## Registering Custom Endpoints ```js (async () => { await octokit.registerEndpoints({ misc: { getRoot: { method: "GET", url: "/", }, }, }); })(); ``` ``` -------------------------------- ### Stop pagination early with octokit.paginate() Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/05_pagination.md To stop paginating before all results are fetched, call the `done()` function within the response map function. Ensure you still return the value to map the response to, otherwise, the last response will be mapped to undefined. ```javascript octokit.paginate( "GET /repos/{owner}/{repo}/issues", { owner: "octokit", repo: "rest.js" }, (response, done) => { if (response.data.find((issue) => issue.body.includes("something"))) { done(); } return response.data; }, ); ``` -------------------------------- ### Access Authentication Token Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/01_authentication.md Retrieve the current authentication token using the `.auth()` method. This is useful for inspecting the token or using it in other contexts. ```javascript const { token } = await appOctokit.auth({ type: "installation", // defaults to `options.auth.installationId` set in the constructor installationId: 123, }); ``` -------------------------------- ### Request Pull Request in Diff Format Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/00_usage.md Request a pull request in a specific format, such as 'diff', by using the `mediaType.format` option. This is useful for comparing changes. ```javascript const { data: diff } = await octokit.rest.pulls.get({ owner: "octokit", repo: "rest.js", pull_number: 123, mediaType: { format: "diff", }, }); ``` -------------------------------- ### Retrieve a Pull Request Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/00_usage.md Use `octokit.rest.pulls.get()` to retrieve details of a specific pull request. Ensure you have the owner, repo, and pull_number. ```javascript const { data: pullRequest } = await octokit.rest.pulls.get({ owner: "octokit", repo: "rest.js", pull_number: 123, }); ``` -------------------------------- ### Request pull request as diff format Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/03_request_formats.md To request a pull request in diff format, set the `mediaType.format` option. This is useful for comparing changes. ```javascript const { data: prDiff } = await octokit.rest.pulls.get({ owner: "octokit", repo: "rest.js", pull_number: 1278, mediaType: { format: "diff", }, }); ``` -------------------------------- ### Abort a request using AbortController Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/03_request_formats.md Use the AbortController interface to abort requests. Pass the AbortSignal instance as an option within the request's options object. Call `controller.abort()` to cancel the request. ```javascript const controller = new AbortController(); const { data: prDiff } = await octokit.rest.pulls.get({ owner: "octokit", repo: "rest.js", pull_number: 1278, request: { signal: controller.signal, }, }); ``` -------------------------------- ### Configure Non-Retryable Status Codes in Octokit Source: https://github.com/octokit/rest.js/blob/main/docs/src/pages/api/00_usage.md Define specific HTTP status codes that should not trigger a retry attempt. The '429' status code is explicitly excluded from retries. ```javascript retry: { doNotRetry: ["429"], } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.