Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e2f28c8

Browse filesBrowse files
todortotevdanielleadams
authored andcommitted
doc: fixup code sample in http.md
PR-URL: #38776 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent a2da9e2 commit e2f28c8
Copy full SHA for e2f28c8

File tree

Expand file treeCollapse file tree

1 file changed

+4
-2
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+4
-2
lines changed
Open diff view settings
Collapse file

‎doc/api/http.md‎

Copy file name to clipboardExpand all lines: doc/api/http.md
+4-2Lines changed: 4 additions & 2 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -2892,7 +2892,9 @@ class. The `ClientRequest` instance is a writable stream. If one needs to
28922892
upload a file with a POST request, then write to the `ClientRequest` object.
28932893

28942894
```js
2895-
const postData = querystring.stringify({
2895+
const http = require('http');
2896+
2897+
const postData = JSON.stringify({
28962898
'msg': 'Hello World!'
28972899
});
28982900

@@ -2902,7 +2904,7 @@ const options = {
29022904
path: '/upload',
29032905
method: 'POST',
29042906
headers: {
2905-
'Content-Type': 'application/x-www-form-urlencoded',
2907+
'Content-Type': 'application/json',
29062908
'Content-Length': Buffer.byteLength(postData)
29072909
}
29082910
};

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.