What do you want to save?
Add Code snippet
New code examples
-
Javascript 2022-03-10 06:20:12
nodejs tcp client
// Include Nodejs' net module. const Net = require('net'); // The port number and hostname of the server. const port = 8080; const host = 'localhost'; // Create a new TCP client. const client = new Net.Socket(); // Send a connection request to the server... Add solution -
Javascript 2022-02-10 07:45:03
include partials ejs
<%- include('partials/header.ejs') %> Add solution -
Other 2022-01-30 19:26:06
error: failed to lookup view "layout" in views directory
Make sure your Express App has this setup, for the current layout it sounds like you have. // Require static assets from public folder app.use(express.static(path.join(__dirname, 'public'))); // Set 'views' directory for any views // being rendered res... Add solution -
Javascript 2021-11-17 14:37:20
require database
const express = require('express'); const cors = require('cors'); const superagent = require('superagent'); const pg = require('pg'); require('dotenv').config(); const app = express(); app.use(cors()); app.use(express.static('public')); app.set('view engi... Add solution -
Javascript 2021-11-14 18:07:28
nodejs write raw buffer to file
/* Using nodejs' fs module you can create a WriteStream to handle raw stream of bytes and buffers. */ const path = "path/to/the/file"; array = BigInt64Array(0); buffer = Buffer.from(array.buffer) fs.createWriteStream(path).write(buffer); Add solution -
Javascript 2021-11-10 22:11:12
show data of mongoose in html page using ejs
app.get('/profileface', isLoggedIn, function(req, res) { // mongoose operations are asynchronous, so you need to wait PracticeModel.find({}, function(err, data) { // note that data is an array of objects, not a single object! res.... Add solution -
Javascript 2021-10-28 07:27:13
Set up google OAuth2 Login with Express
/// STEP 2. make main.ejs // include get route, get some data callback, get some data const express = require('express'); const google = require('googleapis').google; const jwt = require('jsonwebtoken'); // Google's OAuth2 client const OAuth2 = google.a... Add solution -
Other 2021-10-19 04:37:04
passport-google-oauth2 cookies
// Required dependencies const express = require('express'); const app = express(); const passport = require('passport'); const GoogleStrategy = require('passport-google-oauth20'); const cookieSession = require('cookie-session'); // cookieSession config... Add solution