Views not loading express/Node.js

Asked

Viewed 137 times

0

I created a shirt folder inside the Views folder, and when directing the ejs file to be opened 'Marvel.ejs' it cannot find. Only finds if I put Marvel.ejs inside the Views folder and in no subfolder.inserir a descrição da imagem aqui

The page path is having no problem, just to render the ejs file.

1 answer

0


You are exchanging tools that Express.js offers you.

The app.use([path,] callback [, callback...]) wait as first parameter o url or a Regexp to handle urls. Then to display the tab you use the res.render(view [, locals] [, callback]) and then yes, it waits the way to the board where you have the views.

So your code should be (simplified):

app.use('/meu-url', (req, res) => {
    res.render('/camisa/marvel');
});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.