Skip to content

Commit 826ae9b

Browse files
todortotevrichardlau
authored andcommitted
doc: fixup code sample in http.md
PR-URL: #38776 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
1 parent a6f8ba8 commit 826ae9b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

doc/api/http.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2831,7 +2831,9 @@ class. The `ClientRequest` instance is a writable stream. If one needs to
28312831
upload a file with a POST request, then write to the `ClientRequest` object.
28322832

28332833
```js
2834-
const postData = querystring.stringify({
2834+
const http = require('http');
2835+
2836+
const postData = JSON.stringify({
28352837
'msg': 'Hello World!'
28362838
});
28372839

@@ -2841,7 +2843,7 @@ const options = {
28412843
path: '/upload',
28422844
method: 'POST',
28432845
headers: {
2844-
'Content-Type': 'application/x-www-form-urlencoded',
2846+
'Content-Type': 'application/json',
28452847
'Content-Length': Buffer.byteLength(postData)
28462848
}
28472849
};

0 commit comments

Comments
 (0)