Skip to content

Return view in controller AdonisJS

How can I return a view and display it through the controller in AdonisJs

'use strict'
class PostController {
    return view.render('welcome')
module.exports = PostController

report this error:

view is not defined


You can use response.send(view.render('<your_view>'))

Something like:

index({ response, view }){ // Get objects from HTTP Context
  return response.send(view.render('welcome'))

HTTP Context documentation

Official forum answer