What do you want to save?
Add Code snippet
New code examples
-
Javascript 2021-11-17 19:14:11
how to connect to mongoose and create a model
const express = require('express'); const app = express(); const mongoose = require('mongoose'); const bodyParser = require('body-parser'); app.use(bodyParser.json()); const PORT = process.env.PORT || 3000; //connecting to db try { mongoose.conne... Add solution -
Javascript 2021-11-16 06:16:24
host angular app on node server
const express = require('express'); const http = require('http'); const path = require('path'); const app = express(); const port = process.env.PORT || 3001; app.use(express.static(__dirname + '/dist/my-app-name')); app.get('/*', (req, res) => res.... Add solution -
Javascript 2021-11-15 18:43:10
set proxy to use nodejs in angular
// in NodeJS (3000 port) make: app.get('/api/user', (req, res) => { res.json({}); }); // in Angular (4200 port): // make call async ngOnInit(): Promise<void> { let result = await this.http.get("http://127.0.0.1:4200/api/user").to... Add solution -
Javascript 2021-11-12 02:10:11
what is the meanof using next in nodejs
/* Some people always write return next() is to ensure that the execution stops after triggering the callback. If you don't do it, you risk triggering the callback a second time later, which usually has devastating results. */ app.get('/users/:id?', fu... Add solution -
Javascript 2021-11-11 18:47:19
how to use of socket io on a route in nodejs
//Using Express 4, in your app.js file you can use app.set('socketio', io); //then in your router you can access it like this router.post('/getRides', function(req, res, next) { var io = req.app.get('socketio'); io.to(//socket.id//).emit("m... Add solution -
Javascript 2021-11-11 18:44:10
node js express
const express = require('express'); const app = express(); const PORT = process.env.PORT || 3000; app.get('/', (req, res) => { res.send('<h1>Some HTML</h1>'); res.send('<p>Even more HTML</p>'); }); app.listen(PORT, () =>... Add solution