Hapi js redirect to another route with additional request data

In hapi.js, I can redirect the request from the 1st route to another using

response.redirect('/home') 

How to send some data when redirecting? I tried to set it in the headers

 response.redirect('/home').header('x-token', token) 

but this data will be lost when it reaches another route.

+5
source share
1 answer

You can use Yar https://github.com/hapijs/yar

 request.yar.set('example', { key: 'value' }); response.redirect('/home') 

In the home route:

 var example = request.yar.get('example'); // this will be "value" 
+3
source

All Articles