when I use ctx.redirect
, koa just sends GET request but not actually redirect the tab to other page from where It was. I'm just trying to redirect to user's page after signup. Here's code.
signup
router.post('/signup', async (ctx, next) => {
let data = ctx.request.body
const param = await makeParam(data)
try {
const user = new User(param)
await user.save()
ctx.redirect(`/u/${data.username}`)
} catch (e) {
console.error("Failed to save post request", e, param)
}
})
and here's the router for userpage
router.get('/:userName', async (ctx, next) => {
let userName = ctx.params.userName
let renderData = {
userName: userName,
profilePic: "",
itemCount: "",
contentCount: "",
joinedDate: "",
lastVisited: ""
}
await ctx.render('form/form4', renderData)
})