Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hapi js redirecting to another route with additional request data

In hapi.js i can redirect request from 1 route to another using

response.redirect('/home')

How do i send some data with the redirection? I tried setting it in headers

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

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

like image 916
sravis Avatar asked Apr 30 '16 08:04

sravis


1 Answers

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

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

In home route:

var example = request.yar.get('example'); // this will be "value"
like image 87
michelem Avatar answered Oct 14 '22 16:10

michelem