| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2892,7 +2892,9 @@ class. The `ClientRequest` instance is a writable stream. If one needs to | |||
| 2892 | 2892 | upload a file with a POST request, then write to the `ClientRequest` object. | |
| 2893 | 2893 | ||
| 2894 | 2894 | ```js | |
| 2895 | - const postData = querystring.stringify({ | ||
| 2895 | + const http = require('http'); | ||
| 2896 | + | ||
| 2897 | + const postData = JSON.stringify({ | ||
| 2896 | 2898 | 'msg': 'Hello World!' | |
| 2897 | 2899 | }); | |
| 2898 | 2900 | ||
@@ -2902,7 +2904,7 @@ const options = { | |||
| 2902 | 2904 | path: '/upload', | |
| 2903 | 2905 | method: 'POST', | |
| 2904 | 2906 | headers: { | |
| 2905 | - 'Content-Type': 'application/x-www-form-urlencoded', | ||
| 2907 | + 'Content-Type': 'application/json', | ||
| 2906 | 2908 | 'Content-Length': Buffer.byteLength(postData) | |
| 2907 | 2909 | } | |
| 2908 | 2910 | }; | |
| Back | FazBrowse Home | New Git URL |
0 commit comments