Skip to content

Commit 5a67f15

Browse files
todortotevjasnell
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 46eb417 commit 5a67f15

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
@@ -2898,7 +2898,9 @@ class. The `ClientRequest` instance is a writable stream. If one needs to
28982898
upload a file with a POST request, then write to the `ClientRequest` object.
28992899

29002900
```js
2901-
const postData = querystring.stringify({
2901+
const http = require('http');
2902+
2903+
const postData = JSON.stringify({
29022904
'msg': 'Hello World!'
29032905
});
29042906

@@ -2908,7 +2910,7 @@ const options = {
29082910
path: '/upload',
29092911
method: 'POST',
29102912
headers: {
2911-
'Content-Type': 'application/x-www-form-urlencoded',
2913+
'Content-Type': 'application/json',
29122914
'Content-Length': Buffer.byteLength(postData)
29132915
}
29142916
};

0 commit comments

Comments
 (0)