Create a server using HTTP
Anonymous
const express = require(‘express’); const app = express(); const mongoose = require(‘mongoose’); const host = ‘localhost’ const port = 2000 mongoose.connect(‘mongodb://localhost/server’) .then(() => { console.log(‘connected’); app.listen(port, host, () => { console.log(‘server is listening on’ + host + ‘:’ + port); } ) .catch( (error) => { console.log(‘Error occurred while connecting to the server’, error.message); } )
Check out your Company Bowl for anonymous work chats.