Nodejs Code Samples



Filters


How to use async-await with promises in nodejs
harika | 1 month
const mul = (a, b) => {
  return new Promise((resolve, reject)=> {
    setTimeout(()=>{
nodejs javascript async
How to Connect to a mongodb database using mongodb in nodejs
harika | 1 month
const {MongoClient, ObjectID} = require("mongodb");
const ConnectionURL = "mongodb://127.0.0.1:2701
nodejs javascript nodemon
Create webserver using expressjs
harika | 1 month, 1 week
//server.js
const express = require("express")
const app = express()
Prerequisites : express suppose to be installed If not try npm i express inside the project folde
nodejs route javascript
How to Connect to a mongodb database using mongoose in nodejs
harika | 1 month
const mongoose = require("mongoose");
mongoose.connect("mongodb://127.0.0.1:27018/koder-mongo-app",
nodejs mongoose javascript
How to use callbacks in node js
harika | 1 month, 1 week
//add.js
const add = (p1, p2, callback) => {
setTimeout(()=>{
try to run the file with node Ex: node add.js
nodejs javascript async
How to serve static pages using expressjs
harika | 1 month
//app.js
const path = require("path");
const express = require("express")
the app.js and index.html suppose to be in the same directory. try to run nodemon app.js, you can s
nodejs javascript path
https requests and callbacks in nodejs
harika | 1 month, 1 week
//ex.js
const https = require('https')
const url = "" //Use the url you want to get the data from
try to run the file with the help of node node ex.js
nodejs callback javascript
Promise Chaining in nodejs
harika | 1 month
const mul = (a, b) => {
  return new Promise((resolve, reject)=> {
    setTimeout(()=>{
nodejs python async
Write a basic promise in nodejs
harika | 1 month
const mul = (a, b) => {
  return new Promise((resolve, reject)=> {
    setTimeout(()=>{
nodejs async javascript