0

Не могу решить как рендерить запросы, Чистые запросы получается вывести в ctx.body но не получается в рендеринге вывести

router.get('/user', async(ctx) => {
  auth(ctx);
  try {
    let orders = Order.find((err, doc) => {
      return doc;
    });
    await ctx.render('user', {
      title: 'Главнвя страница',
      username: ctx.state.user,
      order: orders
    });
  } catch (err) {
    await console.log(err);
  }
});

function auth(ctx) {
  if (!ctx.isAuthenticated()) {
    ctx.redirect('/');
  }
}
mixin gridView()
    each val in order
        tr
          td=val.orderId
          td=val.time
          td=val.description
          td=val.tag
          td=val.shipping
          td=val.juid
          td=val.status

Я сделал pug шаблонизатор, поэтому привел такой код вывода. То есть так выводит ошибку Cannot read property 'orderId' of undefined

1 ответ 1

1

router.get('/user', async(ctx) => {
  auth(ctx);
  try {
    let orders = await Order.find((err, doc) => {
      return doc;
    });
    return ctx.render('user', {
      title: 'Главнвя страница',
      username: ctx.state.user,
      order: orders
    });
  } catch (err) {
    await console.log(err);
  }
});

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.