H
H
hollanditkzn2017-11-23 10:14:53
Node.js
hollanditkzn, 2017-11-23 10:14:53

Render requests with mongoose to koa?

I can’t decide how to render requests, I can display clean requests in ctx.body but I can’t output them in rendering

router.get('/user', async(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);
  }
});

In pug template engine
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

That is, it displays the error Cannot read property 'orderId' of undefined

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hollanditkzn, 2017-11-23
@hollanditkzn

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);
        }
    });

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question