Skip to content

Commit

Permalink
doc: fixup code sample in http.md
Browse files Browse the repository at this point in the history
PR-URL: #38776
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
  • Loading branch information
todortotev authored and richardlau committed Jul 20, 2021
1 parent a6f8ba8 commit 826ae9b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions doc/api/http.md
Expand Up @@ -2831,7 +2831,9 @@ class. The `ClientRequest` instance is a writable stream. If one needs to
upload a file with a POST request, then write to the `ClientRequest` object.

```js
const postData = querystring.stringify({
const http = require('http');

const postData = JSON.stringify({
'msg': 'Hello World!'
});

Expand All @@ -2841,7 +2843,7 @@ const options = {
path: '/upload',
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(postData)
}
};
Expand Down

0 comments on commit 826ae9b

Please sign in to comment.