Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

node api with mongodb

require('dotenv').config();

const express = require('express');
const mongoose = require('mongoose');
const mongoString = process.env.DATABASE_URL;

mongoose.connect(mongoString);
const database = mongoose.connection;

database.on('error', (error) => {
    console.log(error)
})

database.once('connected', () => {
    console.log('Database Connected');
})
const app = express();

app.use(express.json());

app.listen(3000, () => {
    console.log(`Server Started at ${3000}`)
})
Comment

PREVIOUS NEXT
Code Example
Javascript :: Sort by month name javascript 
Javascript :: delete value from an array javascript 
Javascript :: javascript map() method 
Javascript :: set placeholder javascript 
Javascript :: delete icon 
Javascript :: run only one test cypress 
Javascript :: how to stop requestanimationframe in javascript 
Javascript :: how to clear textbox in javascript 
Javascript :: nodejs cdn 
Javascript :: html table to csv javascript 
Javascript :: react router native back button 
Javascript :: conditional rendering react 
Javascript :: dom 
Javascript :: Ternary Expressions in JavaScript 
Javascript :: http_proxy 
Javascript :: private routing in react 
Javascript :: req.header express.js 
Javascript :: javascript spread syntax 
Javascript :: adding cors in angular 
Javascript :: remove two things from javascript string 
Javascript :: AJAX - XMLHttpRequest 
Javascript :: find in javascript 
Javascript :: vue component naming convention 
Javascript :: npm ERR! missing script: build:dev 
Javascript :: load a component on button click react 
Javascript :: materialze 
Javascript :: react tutorial 
Javascript :: node red push to array 
Javascript :: typeahead bootstrap 4 add multiple values 
Javascript :: how to firebase.database().ref push unique id in same unique id firebase 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =