Repository navigation
Fix ReferenceError: import Octokit on GHES in REST scripting guide - #47109
ShakilUrRehman21 wants to merge 1 commit into
Conversation
How to review these changes 👓Thank you for your contribution. To review these changes, choose one of the following options: A Hubber will need to deploy your changes internally to review. Table of review linksNote: Please update the URL for your staging server or codespace. The table shows the files in the
Key: fpt: Free, Pro, Team; ghec: GitHub Enterprise Cloud; ghes: GitHub Enterprise Server 🤖 This comment is automatically generated. |
There was a problem hiding this comment.
🟢 Approval recommended
The change addresses the GHES-specific ReferenceError by conditionally importing Octokit where Octokit.defaults is used, with no active review issues reported.
No open issues 🎉
What changed in this PR
This PR fixes a GHES-specific ReferenceError in the REST API JavaScript scripting guide by conditionally importing Octokit where the example uses Octokit.defaults.
Changes:
- Conditionally imports
OctokitalongsideAppfor GHES documentation builds. - Preserves the existing
App-only import for other supported versions.
| File | Description |
|---|---|
| content/rest/guides/scripting-with-the-rest-api-and-javascript.md | Updates the GitHub App authentication example to conditionally import Octokit for GHES. |
Review effort: Lite
Why:
In
content/rest/guides/scripting-with-the-rest-api-and-javascript.md, the example for authenticating with a GitHub App configuresOctokit.defaults({ baseUrl: ... })when targeting GitHub Enterprise Server (ghes):Because line 59 only imports
Appfrom"octokit", referencingOctokit.defaultson GHES causes a runtime error:This PR updates the import statement to conditionally import
Octokitwhen on GHES (import { App{% ifversion ghes %}, Octokit{% endif %} } from "octokit";), matching the established pattern incontent/apps/creating-github-apps/writing-code-for-a-github-app/building-a-github-app-that-responds-to-webhook-events.md.What's being changed:
content/rest/guides/scripting-with-the-rest-api-and-javascript.mdto importOctokitalongsideApponghesversions.Check off the following: