How to use callbacks in node js

async javascript callback nodejs 5 years, 2 months ago
//add.js const add = (p1, p2, callback) => { setTimeout(()=>{ callback(p1+p2); }, 2000) } add(3,5,(sum)=>{ console.log(sum) })
1153
Instructions

try to run the file with node
Ex: node add.js

Posted By
https requests and callbacks in nodejs
//ex.js
const https = require('https')
const url = "" //Use the url you want to
nodejs callback javascript http https
harika
Create webserver using expressjs
//server.js
const express = require("express")
const app = express()
nodejs route javascript expressjs
harika
How to serve static pages using expressjs
//app.js
const path = require("path");
const express = require("express")
nodejs javascript path expressjs static pages
harika
Write a basic promise in nodejs
const mul = (a, b) => {
  return new Promise((resolve, reject)=>
    setTimeout(()=>{
nodejs async javascript promise
harika
Promise Chaining in nodejs
const mul = (a, b) => {
  return new Promise((resolve, reject)=>
    setTimeout(()=>{
nodejs python async promise
harika
How to use async-await with promises in nodej
const mul = (a, b) => {
  return new Promise((resolve, reject)=>
    setTimeout(()=>{
nodejs javascript async await promise
harika
How to Connect to a mongodb database using mo
const {MongoClient, ObjectID} = require(
const ConnectionURL = "mongodb://127.0.0
const DBName = "koder-mongo-app";
nodejs javascript nodemon mongodb
harika
How to Connect to a mongodb database using mo
const mongoose = require("mongoose");
mongoose.connect("mongodb://127.0.0.1:27
  useNewUrlParser: true,
nodejs mongoose javascript nodemon mondodb
harika
Work with inline styles in React js
//plugin to any test js file and proceed
//This is the best standard to work with
const style = {background:'cyan', color:
javascript react js css
harika
Work with 3rd party css libraries in react fr
import React from 'react'
//No need to give the complete path, rea
//If not exists searches globally
javascript react js
harika
work with react without node installation in
//Basic way
<!DOCTYPE html>
<html>
javascript react js html
harika
Difference between state and stateless compon
//State Component
<!DOCTYPE html>
<html>
javascript react js
harika
Create a React app without webpack and Create
//Basic way
<!DOCTYPE html>
<html>
javascript react js webpack
harika
JQuery toggle functionality in react
import React from 'react'
export default class ToggleComponent ext
  constructor(props){
javascript react js
harika
display state inside any html tag
import React from 'react'
export default class StateProps extends 

javascript react js
harika
Import any class irrespective of default expo
import React, { Component } from 'react'
javascript react js
harika
Run Java script code Synchronously inside a f
async function showAvatar() {

  // read our JSON
javascript
harika
Run shell files in javascript
//JS Code
function runShellScript(){
    const process = require('child_proce
javascript shell node js
harika
XHR Request & Ajax Request
//Fill
javascript
harika
Pass Data/Properties from child to parent in
//Parent.js
import React from "react";
import Child from './Child'
javascript react js
harika