| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 56aaf70 commit aff0cd3
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2287,7 +2287,7 @@ The `callback` is invoked with a single argument that is an instance of | |||
| 2287 | 2287 | JSON fetching example: | |
| 2288 | 2288 | ||
| 2289 | 2289 | ```js | |
| 2290 | - http.get('http://nodejs.org/dist/index.json', (res) => { | ||
| 2290 | + http.get('http://localhost:8000/', (res) => { | ||
| 2291 | 2291 | const { statusCode } = res; | |
| 2292 | 2292 | const contentType = res.headers['content-type']; | |
| 2293 | 2293 | ||
@@ -2322,6 +2322,16 @@ http.get('http://nodejs.org/dist/index.json', (res) => { | |||
| 2322 | 2322 | }).on('error', (e) => { | |
| 2323 | 2323 | console.error(`Got error: ${e.message}`); | |
| 2324 | 2324 | }); | |
| 2325 | + | ||
| 2326 | + // Create a local server to receive data from | ||
| 2327 | + const server = http.createServer((req, res) => { | ||
| 2328 | + res.writeHead(200, { 'Content-Type': 'application/json' }); | ||
| 2329 | + res.end(JSON.stringify({ | ||
| 2330 | + data: 'Hello World!' | ||
| 2331 | + })); | ||
| 2332 | + }); | ||
| 2333 | + | ||
| 2334 | + server.listen(8000); | ||
| 2325 | 2335 | ``` | |
| 2326 | 2336 | ||
| 2327 | 2337 | ## `http.globalAgent` | |
| Back | FazBrowse Home | New Git URL |
0 commit comments