Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
1 task done
esqb opened this issue May 21, 2021 · 5 comments
Closed
1 task done

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

esqb opened this issue May 21, 2021 · 5 comments
Labels
doc Issues and PRs related to the documentations. good first issue Issues that are suitable for first-time contributors.

Comments

@esqb
Copy link

esqb commented May 21, 2021

馃摋 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.
@esqb esqb added the doc Issues and PRs related to the documentations. label May 21, 2021
@Ayase-252
Copy link
Member

Thanks for catching this.

Line #1
const postData = JSON.stringify({

I'd agree with this change, since querystring module has been marked as legacy. Replace it with JSON.stringify is right here.

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

I'd prefer the alternative. const http = require('http'); is more common way to use module.

@aduh95 aduh95 added the good first issue Issues that are suitable for first-time contributors. label May 22, 2021
@himanshu007-creator
Copy link

Hi, I would like to work on this issue馃檪

@esqb
Copy link
Author

esqb commented May 23, 2021

Thanks for catching this.

Line #1
const postData = JSON.stringify({

I'd agree with this change, since querystring module has been marked as legacy. Replace it with JSON.stringify is right here.

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

I'd prefer the alternative. const http = require('http'); is more common way to use module.

You're welcome! I'm glad I was able to contribute.

@Pulkit3234
Copy link

Hi, Is anyone working on this issue? If not, I would like to take this issue!

@Ayase-252
Copy link
Member

@Pulkit3234

Thanks for interest, but it has been resolved #38776, you could look https://www.nodetodo.org/next-steps/ to find any issue you may be interested in.

Also, closing as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. good first issue Issues that are suitable for first-time contributors.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants