web/routes/api.js

19 lines
528 B
JavaScript
Raw Normal View History

2021-11-15 10:59:21 +01:00
const express = require('express')
const router = express.Router()
const db = require('../modules/db')
router.get('/getproducts', (req, res) => {
const conn = db.connect();
2021-11-15 11:56:01 +01:00
conn.execute('SELECT * FROM `products`', [], function(err, results) {
2021-11-15 10:59:21 +01:00
res.json(results);
});
})
router.get('/getproduct', (req, res) => {
const conn = db.connect();
2021-11-15 11:56:01 +01:00
conn.execute('SELECT * FROM `products` WHERE `ID` = ?', [req.query.id], function(err, results) {
2021-11-15 10:59:21 +01:00
res.json(results);
});
})
module.exports = router;