I actually found this site and got my ajax connection done. I set up the table for progressive loading but the data isnt showing up. (Because it's not retrieving an array)
The data looks like the following:
{"payload":[{"Register":1,"Druck":59,"Zeitstempel":"13:37:41:967"},{"Register":2,"Druck":59,"Zeitstempel":"13:37:41:967"},{"Register":3,"Druck":59,"Zeitstempel":"13:37:41:967"},{"Register":4,"Druck":59,"Zeitstempel":"13:37:41:967"},{"Register":5,"Druck":59,"Zeitstempel":"13:37:41:967"},{"Register":6,"Druck":59,"Zeitstempel":"13:37:41:967"},{"Register":7,"Druck":59,"Zeitstempel":"13:37:41:967"},{"Register":8,"Druck":59,"Zeitstempel":"13:37:41:967"},{"Register":9,"Druck":59,"Zeitstempel":"13:37:41:967"},{"Register":10,"Druck":59,"Zeitstempel":"13:37:41:967"},{"Register":11,"Druck":59,"Zeitstempel":"13:37:41:967"},{"Register":12,"Druck":59,"Zeitstempel":"13:37:41:967"},{"Register":13,"Druck":59,"Zeitstempel":"13:37:41:967"},{"Register":14,"Druck":59,"Zeitstempel":"13:37:41:967"},{"Register":15,"Druck":59,"Zeitstempel":"13:37:41:967"},{"Register":16,"Druck":59,"Zeitstempel":"13:37:41:967"}]}
I think I have to change something inside the server file..
var express = require('express')
var path = require('path')
var createError = require('http-errors')
var cors = require('cors')
var bodyParser = require('body-parser')
var app = express()
var dbMySQLNode = require('./database')
// view engine setup
app.set('views', path.join(__dirname, '/'))
app.set('view engine', 'ejs')
app.use(bodyParser.json())
app.use(
bodyParser.urlencoded({
extended: true,
}),
)
app.use(cors())
app.get('/', (req, res) => {
res.render('index')
})
app.get('/fetch-countries', function (req, res) {
dbMySQLNode.query('SELECT * FROM Country ORDER BY id desc', function (
error,
response,
) {
if (error) {
res.json({
msg: error,
})
} else {
res.json({
msg: 'Data successfully fetched',
country: response,
})
}
})
})
app.listen(5555, function () {
console.log('Node app is being served on port: 5555')
})
module.exports = app
But I have no clue about express or body-parser...