Javascript Code Samples



Filters


Create a model and save document in Mongo db using Mongoose and Node JS
kishore_kumar | 7 years, 6 months
const mongoose = require("mongoose")

mongoose.connect("mongodb://127.0.0.1:27017/my-db", {
mongoose javascript node js
How to use async-await with promises in nodejs
harika | 7 years, 1 month
const mul = (a, b) => {
  return new Promise((resolve, reject)=> {
    setTimeout(()=>{
nodejs javascript async
Create a simple web server with express using Node js
kishore_kumar | 7 years, 6 months
const express = require('express')

const app = express()
express javascript node js
How to Connect to a mongodb database using mongodb in nodejs
harika | 7 years, 1 month
const {MongoClient, ObjectID} = require("mongodb");
const ConnectionURL = "mongodb://127.0.0.1:2701
nodejs javascript nodemon
Load native javascript inside webview in react-native
harika | 6 years, 9 months
import React, { Component } from 'react';
import {View,  WebView} from 'react-native-webview';

install react-native-webview using npm npm i react-native-webview --save try to load the compo
html react-native webview
Dynamic templating using express and handlebars
harika | 7 years, 1 month
//app.js
const path = require("path");
const express = require("express")
express dynamic templating javascript
Run shell files in javascript
harika | 8 years, 3 months
//JS Code
function runShellScript(){
    const process = require('child_process'); 
keep the function code inside the js file wherever you want to use. and keep the shell file provided
javascript shell node js
Adjust browser height and width according to device / Screen height and width in electron app
harika | 7 years, 10 months
import electron from 'electron';
const screenElectron = electron.screen;
const mainScreen = screen
Add the piece of code while creating window in main.js and check the difference. Happy Coding :-)
javascript electron js
Compress files synchronously in javascript
harika | 7 years, 11 months
const tar = require('tar');
  tar.c(
    {
try to install 'tar' using npm and then try. Happy Coding :-)
node js javascript react js
Create webserver using expressjs
harika | 7 years, 1 month
//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
Prev Next