Endpoint name

This commit is contained in:
Fabio Manganiello 2025-02-19 19:43:30 +01:00
parent 53ae3e2998
commit 374054ef1f
3 changed files with 7 additions and 5 deletions

8
app.js
View file

@ -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,
});

View file

@ -13,4 +13,4 @@
"pg": "^8.7.1",
"sequelize": "^6.6.5"
}
}
}

View file

@ -1,5 +1,5 @@
async function getGpsData() {
return await fetch('/get')
return await fetch('/gpsdata')
}
document.addEventListener('DOMContentLoaded', () => {