Some API endpoints support alternative response formats, see Media types.

For example, to request a pull request as diff format, set the mediaType.format option

const { data: prDiff } = await octokit.pulls.get({
owner: "octokit",
repo: "rest.js",
pull_number: 1278,
mediaType: {
format: "diff",
},
});

The AbortController interface can be used to abort one or more requests as and when desired. When the request is initiated, an AbortSignal instance can be passed as an option inside the request's options object. For usage in Node, the abort-controller package can be used.

const controller = new AbortController();
const { data: prDiff } = await octokit.pulls.get({
owner: "octokit",
repo: "rest.js",
pull_number: 1278,
request: {
signal: controller.signal,
},
});

Use controller.abort() to abort the request when desired.