1

Is it possible to configure nested routes/views with HapiJS?

For example if we navigate to the following route it would display a list of movies:

{
    method: 'GET',
    path: '/movies',
    handler: function(request, reply) {
        return reply.view('movies', {
            data: MOVIES_LIST
        });
    }
}

When we select a movie from that list we navigate to the following route:

{
    method: 'GET',
    path: '/movies/{movie_id}',
    handler: function(request, reply) {
        return reply.view('movie', {
            data: SELECTED_MOVIE
        });
    }
}

Then we should render the movie view as nested from the movies route.

UPDATE

enter image description here

aqua
  • 377
  • 4
  • 17
  • 1
    What's the problem with the code above? – Gergo Erdosi May 02 '15 at 14:44
  • 1
    You can access the {movie_id} param in your handler by using: request.params.movie_id. Is that what you're asking? – Kevin Wu May 02 '15 at 20:27
  • I think my question was misunderstood. My question is about nested views with HapiJS view system. I have updated the original question by adding an example, please take a look. – aqua May 03 '15 at 18:56
  • Question looks similar to http://stackoverflow.com/q/29143194/946789 – c69 May 03 '15 at 19:03

0 Answers0