Skip to content

Fix JavaScript arrow function SyntaxError in REST API examples - #47075

Merged
subatoi merged 1 commit into
github:mainfrom
ShakilUrRehman21:fix/rest-api-arrow-syntax-error
Nov 26, 2026
Merged

subatoi merged 1 commit into
github:mainfrom
ShakilUrRehman21:fix/rest-api-arrow-syntax-error

Conversation

@ShakilUrRehman21

Copy link
Copy Markdown
Contributor

Why:

Closes: N/A

In content/rest/quickstart.md and content/rest/using-the-rest-api/getting-started-with-the-rest-api.md, the example JavaScript snippet for mapping through API results contains an invalid arrow function expression:

const titleAndAuthor = result.data.map(issue => {title: issue.title, authorID: issue.user.id})

Because { ... } in an arrow function body is parsed by JavaScript as a block statement with a label (title:) rather than an object literal, running this code in Node.js throws a fatal error:

SyntaxError: Unexpected token ':'

Wrapping the returned object literal in parentheses (({ ... })) resolves the syntax error so users running the tutorial code can execute it without failure.

What's being changed (if available, include any code snippets, screenshots, or gifs):

Updated the arrow function to issue => ({ title: issue.title, authorID: issue.user.id }) in:

  • content/rest/quickstart.md
  • content/rest/using-the-rest-api/getting-started-with-the-rest-api.md

Before:
const titleAndAuthor = result.data.map(issue => {title: issue.title, authorID: issue.user.id})

After:
const titleAndAuthor = result.data.map(issue => ({ title: issue.title, authorID: issue.user.id }))

Check off the following:

  • A subject matter expert (SME) has reviewed the technical accuracy of the content in this PR. In most cases, the author can be the SME. Open source contributions may require an SME review from GitHub staff.
  • The changes in this PR meet the docs fundamentals that are required for all content.
  • All CI checks are passing and the changes look good in the review environment.

Copilot AI lite review requested due to automatic review settings November 26, 2026 13:50
@welcome

welcome Bot commented Nov 26, 2026

Copy link
Copy Markdown

Thanks for opening this pull request! A GitHub docs team member should be by to give feedback soon. In the meantime, please check out the contributing guidelines.

@github-actions github-actions Bot added the triage Do not begin working on this issue until triaged by the team label Nov 26, 2026
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

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 links

Note: Please update the URL for your staging server or codespace.

The table shows the files in the content directory that were changed in this pull request. This helps you review your changes on a staging server. Changes to the data directory are not included in this table.

Source Review Production What Changed
rest/quickstart.md fpt
ghec
ghes@ 3.23 3.22 3.21 3.20 3.19
fpt
ghec
ghes@ 3.23 3.22 3.21 3.20 3.19
rest/using-the-rest-api/getting-started-with-the-rest-api.md fpt
ghec
ghes@ 3.23 3.22 3.21 3.20 3.19
fpt
ghec
ghes@ 3.23 3.22 3.21 3.20 3.19

Key: fpt: Free, Pro, Team; ghec: GitHub Enterprise Cloud; ghes: GitHub Enterprise Server

🤖 This comment is automatically generated.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

An active documentation issue remains because an unnecessary HTML directive is rendered inside fenced shell examples and may be copied as part of the API response, appearing in two locations.

1 open issue
What changed in this PR

This pull request fixes invalid JavaScript arrow-function syntax in REST API documentation examples so mapped object literals are returned correctly.

Changes:

  • Wraps the returned object literals in parentheses in both JavaScript examples.
  • Adds Markdown lint suppressions to two HTTP response examples.
File Description
content/​rest/​using-the-rest-api/​getting-started-with-the-rest-api.md Fixes the JavaScript mapping example and adds lint suppressions to two HTTP response examples.
content/​rest/​quickstart.md Fixes the JavaScript mapping example to use valid arrow-function syntax.

Review effort: Lite

@ShakilUrRehman21
ShakilUrRehman21 force-pushed the fix/rest-api-arrow-syntax-error branch from ecc89d6 to b72e0c0 Compare November 26, 2026 14:17

@subatoi subatoi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spotting that and raising a fix, @ShakilUrRehman21. I'll get this merged now

@subatoi
subatoi added this pull request to the merge queue Nov 26, 2026
Merged via the queue into github:main with commit df6faa2 Nov 26, 2026
50 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

Thanks very much for contributing! Your pull request has been merged 🎉 You should see your changes appear on the site in approximately 24 hours. If you're looking for your next contribution, check out our help wanted issues ⚡

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

triage Do not begin working on this issue until triaged by the team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants