lecture.js
676 Bytes
var express = require('express');
var router = express.Router();
var mysql = require('mysql');
var conf = require('../conf/db');
var pool = mysql.createPool(conf.local)
/* GET home page. */
router.get('/:lecture_id', function(req, res, next) {
var lecture_id = req.params.lecture_id;
pool.getConnection(function(err, conn){
conn.query('select * from lecture;', function (err, rows){
if (err) return res.status(500).json({error: err});
if (!rows) return res.status(400).json({error: 'not found'});
var msg = {
status: 'success',
err: '',
result: rows,
length: rows.length
};
res.json(msg);
});
conn.release();
});
});
module.exports = router;