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 :: react.dom 
Javascript :: how to make callback function javascript 
Javascript :: Get a random value from an array in JS 
Javascript :: javascript for...in loop 
Javascript :: get syntethicbaseevent and parameter in react 
Javascript :: javascript array remove last 
Javascript :: dynamic routing 
Javascript :: ng2-tel-input phone number code 
Javascript :: syntax of the ternary operator 
Javascript :: belongstomany sequelize 
Javascript :: how use multi things in in switch case in js 
Javascript :: alert modal 
Javascript :: create react app 
Javascript :: typescript base64 from file 
Javascript :: sort javascript 
Javascript :: javascript list comprehension 
Javascript :: import in react 
Javascript :: redwood js 
Javascript :: push and unshift in javascript 
Javascript :: discord interaction create not working 
Javascript :: get the last element of array javascript 
Javascript :: Angular 4 "Property does not exist on type component" 
Javascript :: working with multiple db in single query mongodb 
Javascript :: js object 
Javascript :: stripe subscription node js 
Javascript :: what is a node 
Javascript :: Array#splice 
Javascript :: how to call function with only selected arguments in javascript 
Javascript :: signup Using codegniter in ajax 
Javascript :: jquery detach and remove 
ADD CONTENT
Topic
Content
Source link
Name
6+6 =