Why is it wrong to throw er; // Unhandled 'error' event?



  • When the server's work is checked, there's a mistake, why?

    введите сюда описание изображения

    Code itself

    const http = require('http');
    const PORT = 3000;
    

    const server = http.createServer((req, res) => {
    console.log('Server request');
    });

    server.listen(PORT, 'localshost', (error) => {
    error ? console.log(error) : console.log('listening port ${PORT}');
    });



  • You have a seal: localshost instead localhost

    Names localshost The computer doesn't know.


Log in to reply
 

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2