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-03-06-rds.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);
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement