What do you want to save?
Add Code snippet
New code examples
-
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-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-09 17:32:08
filter a query string with comparison operator
//if need to find ratings greater then 3 //The query string may be: //127.0.0.1:8000/api/v1/posts?ratings[gt]=3 //if we check the req.query //{ ratings: { gt: '3' } } exports.getPosts = async (req, res) => { try { const queryObj = { ...req.query ... Add solution -
Javascript 2021-11-06 22:48:09
live search using fetch api
const search_input = document.getElementById('search'); const results = document.getElementById('results'); let search_term = ''; let countries; const fetchCountries = async () => { countries = await fetch( 'https://restcountries.eu/rest/... Add solution -
Other 2021-11-05 05:35:17
react sending email via Nodemailer using node.js
const express = require('express'); const mailerRouter = express.Router(); const Nodemailer = require('nodemailer') mailerRouter.post('/email', (req, res) => { const data = req.body console.log(`${data.name}, ${data.email}, ${data.subject}, ${data... Add solution