We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 95025c6 commit 506bad7Copy full SHA for 506bad7
src/connect/connect-echo-example.js
@@ -1,6 +1,7 @@
1
"use strict";
2
import connect from "connect";
3
import http from "http";
4
+import fetch from "node-fetch";
5
import assert from "assert";
6
var app = connect();
7
// add Error handling
@@ -16,6 +17,7 @@ app.use(function (req, res) {
16
17
//create node.js http server and listen on port
18
var server = http.createServer(app).listen(3000, request);
19
20
+var closeServer = server.close.bind(server);
21
// request => response
22
function request() {
23
var requestBody = {
@@ -28,6 +30,5 @@ function request() {
28
30
.then(res => res.text())
29
31
.then(text => {
32
assert.deepEqual(text, requestBody);
- server.close();
- }).catch(console.error.bind(console));
33
+ }).then(closeServer, closeServer);
34
}
0 commit comments