Endpoint name
This commit is contained in:
parent
53ae3e2998
commit
374054ef1f
3 changed files with 7 additions and 5 deletions
8
app.js
8
app.js
|
@ -36,14 +36,16 @@ const GpsData = sequelize.define('GpsData', {
|
|||
app.use(express.static('public'));
|
||||
app.set('view engine', 'ejs');
|
||||
|
||||
// Routes
|
||||
// View route
|
||||
app.get('/', async (req, res) => {
|
||||
res.render('index')
|
||||
});
|
||||
|
||||
app.get('/get', async (req, res) => {
|
||||
// API route
|
||||
app.get('/gpsdata', async (req, res) => {
|
||||
const limit = req.query.limit || 100;
|
||||
const apiResponse = await GpsData.findAll({
|
||||
limit: 1000,
|
||||
limit: limit,
|
||||
offset: 0,
|
||||
});
|
||||
|
||||
|
|
|
@ -13,4 +13,4 @@
|
|||
"pg": "^8.7.1",
|
||||
"sequelize": "^6.6.5"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
async function getGpsData() {
|
||||
return await fetch('/get')
|
||||
return await fetch('/gpsdata')
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
|
|
Loading…
Add table
Reference in a new issue