FACK1 / Countries-autoComplete

0 stars 1 forks source link

Server.listen is an Async function #21

Closed ghassanmas closed 5 years ago

ghassanmas commented 5 years ago

https://github.com/FACK1/Countries-autoComplete/blob/4dd217a462dc2d6c0b4f8f9744226206f99dfc44/src/server.js#L7-L8 The Line 8 may be or mostly will be executed before Line 7 given server.listen is an Async function.

The right way to console.log afrer the the server is start running is by passing the console console.log function in the optinal callback parameter of server.listen as following:

 server.listen(PORT,()=>{ 
 console.log(`server up and running on port ${PORT}!`) 
})
Hadeel-Salamin commented 5 years ago

O.oh! Thanks!

RazanTayyem commented 5 years ago

Thanks , We do it :)