Skip to content

doc: (HTTP) http.request(url[, options][, callback]) sample code error #38760

Closed
@esqb

Description

@esqb

📗 API Reference Docs Problem

Location

API Reference DOCS: (HTTP) http.request(url[, options][, callback])

Affected URL(s):

Description

The first sample code in this item throws an error (ReferenceError) regarding two undefined constants. The first one is 'querystring' on line #1 and the second one is 'http' on line #16. Both are undeclared.

Please view attached screenshot

Actually, both errors can be fixed if the aforementioned lines are updated to:

Line #1
const postData = JSON.stringify({

Line #16
const req = require('http').request(options, (res) => {

An alternative fix for Line #16 could also be leaving as it is, but declaring the constant in the beginning of the code:

const http = require('http');

Screenshot

Screenshot from 2021-05-21 20-26-22


  • I would like to work on this issue and
    submit a pull request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docIssues and PRs related to the documentations.good first issueIssues that are suitable for first-time contributors.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions