Deze code in server.js lijkt nogal op elkaar; misschien is het mogelijk om DRY hier verder op toe te passen
app.get('/', (request, response) => {
let urlSmartzones = `${process.env.API_URL}/smartzones`
fetchJson(urlSmartzones).then((smartzones) => {
let id = request.query.id || 'clene4gw60aqg0bunwwpawr1p'
let url = `${process.env.API_URL}/reservations?id=${id}`
fetchJson(url).then((reservations) => {
let data = {smartzones: smartzones, reservations: reservations}
response.render('index', data)
})
})
})
app.get('/book', (request, response) => {
let urlSmartzones = `${process.env.API_URL}/smartzones`
fetchJson(urlSmartzones).then((smartzones) => {
let id = request.query.id || 'clene4gw60aqg0bunwwpawr1p'
let url = `${process.env.API_URL}/reservations?id=${id}`
fetchJson(url).then((reservations) => {
let data = {smartzones: smartzones, reservations: reservations}
response.render('book', data)
})
})
})