This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const router = express.Router(); | |
const Subscriber = require('../models/subscriber.js'); | |
// GET all subscribers | |
router.get('/', async (req, res) => { | |
try { | |
const subscribers = await Subscriber.find(); // find all in DB | |
res.render('list', { subscribers, alert: null }); | |
// or res.json(subscribers); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('dotenv').config(); | |
const express = require('express'); | |
const app = express(); | |
const mongoose = require('mongoose'); | |
//Uncomment and use a working port | |
//const PORT = 3000; | |
// Mongoose Model | |
const Subscriber = require('./models/subscriber'); |