From e2f28c80d1a44f306ad106796696a794ac9683d9 Mon Sep 17 00:00:00 2001 From: TodorTotev <51530311+TodorTotev@users.noreply.github.com> Date: Sat, 22 May 2021 22:38:58 +0300 Subject: [PATCH] doc: fixup code sample in http.md PR-URL: https://github.com/nodejs/node/pull/38776 Reviewed-By: James M Snell Reviewed-By: Antoine du Hamel --- doc/api/http.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/api/http.md b/doc/api/http.md index e93e2a5d1ba323..0f6ab5343de10a 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -2892,7 +2892,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!' }); @@ -2902,7 +2904,7 @@ const options = { path: '/upload', method: 'POST', headers: { - 'Content-Type': 'application/x-www-form-urlencoded', + 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(postData) } };