my local host isnt loading, i dont know what to do, i have all libraries installed, i already restarted node, my pc, everything ;c
const express = require('express')
const handlebars = require('express-handlebars')
const bodyParser = require('body-parser')
const mongoose = require('mongoose')
const app = express()
//configurações das biblioteca
//bodyparser
app.use(bodyParser.urlencoded({extended: true}))
app.use(bodyParser.json)
// handlebars
app.engine('handlebars', handlebars({defaultLayout: 'main'}))
app.set('view engine', handlebars)
// mongoose
mongoose.Promise = global.Promise;
mongoose.connect("mongodb://localhost/nomedobanco").then(() => {
console.log("conectado com sucesso")
}).catch((err) => {
console.log("deu um erro"+err)})
//pasta de arquivos estáticos (como bootsrap)
//rotas
app.get('/', (req, res) => {
res.render('oi')
})
app.listen(8080)
[localhost not loading[1] [1]: https://i.sstatic.net/yat60.png
You should probably change line from
app.use(bodyParser.json)
to
app.use(bodyParser.json())
You should also fix how handlebars are set
const hbs = handlebars.create({defaultLayout: 'main'});
app.engine('handlebars', hbs.engine)
app.set('view engine', 'handlebars')