| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,7 @@ | |||
| 1 | 1 | "use strict"; | |
| 2 | 2 | import connect from "connect"; | |
| 3 | 3 | import http from "http"; | |
| 4 | + import fetch from "node-fetch"; | ||
| 4 | 5 | import assert from "assert"; | |
| 5 | 6 | var app = connect(); | |
| 6 | 7 | // add Error handling | |
@@ -16,6 +17,7 @@ app.use(function (req, res) { | |||
| 16 | 17 | //create node.js http server and listen on port | |
| 17 | 18 | var server = http.createServer(app).listen(3000, request); | |
| 18 | 19 | ||
| 20 | + var closeServer = server.close.bind(server); | ||
| 19 | 21 | // request => response | |
| 20 | 22 | function request() { | |
| 21 | 23 | var requestBody = { | |
@@ -28,6 +30,5 @@ function request() { | |||
| 28 | 30 | .then(res => res.text()) | |
| 29 | 31 | .then(text => { | |
| 30 | 32 | assert.deepEqual(text, requestBody); | |
| 31 | - server.close(); | ||
| 32 | - }).catch(console.error.bind(console)); | ||
| 33 | + }).then(closeServer, closeServer); | ||
| 33 | 34 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments