0

I am sending from node to my pug template a json in the response like this:

  res.render("memberships", {
     title: "DashRoc - Membresías",
     settings: JSON.parse(req.session.settings)
  });
  //JSON
  {
     "expirepass": false,
     "memberships": {"view":true}
  }

but when I try to read it in pug it says that the 'view' object is not found.

  if settings.memberships.view
     p You have permission to see the membership

I tried to print the content of settings in the console and the result is positive, I can access the 'view' object.

  script.
     console.log(!{settings}) // result -> {"expirepass":false,"memberships":{"view":true}}

but in pug it won't let me access beyond 'memberships'.

4
  • What is the error message?
    – Konrad
    Commented Apr 9 at 17:52
  • @Konrad imgur.com/zTxtqEE Commented Apr 9 at 18:00
  • The error says that settings.memberships is undefined. Try checking what is a type of settings
    – Konrad
    Commented Apr 9 at 18:02
  • @Konrad i print the 'settings' object in the console and this was the result: imgur.com/ZSRMpgm The 'settings' object was sent in the response res.render('memberships',{'settings':JSON.parse(req.session.settings)}) and req.session.settings is generated from the database result where I save req.session.settings = bdresult[0].settings (RowDataPacket). Commented Apr 9 at 18:10

0

Browse other questions tagged or ask your own question.