sadrak
sadrak

Reputation: 1

error using handlebars #each with node and express

Handlebars: Access has been denied to resolve the property "title" because it is not an "own property" of its parent. You can add a runtime option to disable the check or this warning: See http://localhost:8080/api-reference/runtime-options.html#options-to-control-prototype-access for details Handlebars: Access has been denied to resolve the property "description" because it is not an "own property" of its parent.

Upvotes: 0

Views: 1194

Answers (3)

download the package npm install @handlebars/allow-prototype-access and import this to your app.js const {allowInsecurePrototypeAccess} = require('@handlebars/allow-prototype-access')

and to app.engine()in your app.js use this syntax:

app.engine('handlebars', exphbs({ defaultLayout: 'main', handlebars: allowInsecurePrototypeAccess(Handlebars) },
));
app.set('view engine', 'handlebars',);

Upvotes: 0

H Hassanshahi
H Hassanshahi

Reputation: 101

// Idea Index Page
app.get('/ideas', (req, res) => {
  Test1.find({})
    .sort({date:'desc'})
    .lean()
    .then(ideas => {
      res.render('ideas/index', {
        ideas1: ideas
      });
    });
});

use .lean() and it works properly.

Upvotes: 2

ciorg
ciorg

Reputation: 1

Here's a good discussion on this issue with some suggestions on how to fix it, link . I upgraded my jest package with yarn upgrade-interactive --latest and that fixed the issue for me.

Upvotes: 0

Related Questions