From 55a3ca82585107292590232940b9881ff619b45d 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 1/4] directly import http --- doc/api/http.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/api/http.md b/doc/api/http.md index 5ec542e9011575..d6322cccd71a89 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -2898,6 +2898,8 @@ 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 http = require("http") + const postData = querystring.stringify({ 'msg': 'Hello World!' }); From 65059f4247a2729e96f5024950dd38d0059d877b Mon Sep 17 00:00:00 2001 From: TodorTotev <51530311+TodorTotev@users.noreply.github.com> Date: Sat, 22 May 2021 22:39:11 +0300 Subject: [PATCH 2/4] json stringify instead of querystring.stringify --- doc/api/http.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/http.md b/doc/api/http.md index d6322cccd71a89..cef05950bff6e6 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -2900,7 +2900,7 @@ upload a file with a POST request, then write to the `ClientRequest` object. ```js const http = require("http") -const postData = querystring.stringify({ +const postData = JSON.stringify({ 'msg': 'Hello World!' }); From 2160d1dce0abe7b9ee41cce624d79f4521e24377 Mon Sep 17 00:00:00 2001 From: Todor Totev <51530311+todortotev@users.noreply.github.com> Date: Sun, 23 May 2021 09:46:13 +0300 Subject: [PATCH 3/4] use single quotes and semicolons for consistency Co-authored-by: Voltrex <62040526+VoltrexMaster@users.noreply.github.com> --- doc/api/http.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/http.md b/doc/api/http.md index cef05950bff6e6..ea94319697a132 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -2898,7 +2898,7 @@ 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 http = require("http") +const http = require('http'); const postData = JSON.stringify({ 'msg': 'Hello World!' From 8c5c379eb440945c8ad21aa92169e905e65ab496 Mon Sep 17 00:00:00 2001 From: TodorTotev <51530311+TodorTotev@users.noreply.github.com> Date: Mon, 24 May 2021 09:59:11 +0300 Subject: [PATCH 4/4] application/json instead of x-www-form-urlencoded --- doc/api/http.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/http.md b/doc/api/http.md index ea94319697a132..058fd73bdae4b1 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -2910,7 +2910,7 @@ const options = { path: '/upload', method: 'POST', headers: { - 'Content-Type': 'application/x-www-form-urlencoded', + 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(postData) } };