Skip to content
Permalink
8d5211f807
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
31 lines (24 sloc) 704 Bytes
'use strict'
const Router = require('koa-router')
const Question = require('../models/question')
const router = new Router()
const question = new Question()
router.get('/', async ctx => {
try{
const data = await question.getAllQuestions(ctx.query)
console.log(data)
await ctx.render('home', {Questions: data,title: 'Home'})
}catch(err) {
await ctx.render('error', {message: err.message})
}
})
router.post('/insertquestion', async ctx => {
try{
await question.insertQuestion(ctx.request)
ctx.redirect('/')
}catch(err) {
await ctx.render('error', {message: err.message})
}
})
router.get('/createquestion', async ctx => ctx.render('createquestion'))
module.exports = router