H
H
heIIfire2017-04-16 01:00:47
Node.js
heIIfire, 2017-04-16 01:00:47

Why is Event end throwing an error?

Here is the script and the error

var myserver = require('http').createServer().listen(8080);
myserver.on('request', function(x, y){
  y.write("1");
  x.on('data', function(z){
    console.log(z.toString());
    //process.stdout.write(msg.toString());
  });
  x.on('end', function(){
    y.end();
  });
});

10c79077480943058af1597d6d8135a6.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2017-04-16
@Azperin

Duck, after all, immediately after the end of the x.on('end') request, you also complete the response y.end()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question