Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const express = require('express');
- const app = express();
- const _ = require('lodash');
- const mysql = require('promise-mysql');
- const getConnection = () => mysql.createConnection({
- host: 'training-2019-01-11.cg3svzfufeu1.us-east-2.rds.amazonaws.com',
- user: 'root',
- password: '12345678',
- database: 'memes'
- });
- app.get('/', (req, res) => {
- return getConnection().then((conn) => {
- let selectQuery = conn.query(`select * from memes`);
- return selectQuery.then((memes) => {
- conn.end();
- const meme = _.sample(memes);
- return res.send("A very good meme is: " + meme.name);
- });
- });
- });
- app.listen(3000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement