Static GitHub Issues

[2048] I need access to the req.user and req.ip when using asyncData

prev: TypeError: 'inject' is not a function
next: Need better way to logs error on Server Error page?

Im using asyncData to fetch information from database so that it is rendered serverside .... the information is used to create a chart and show votes on the chart by users. if user hasnt voted on chart they have the option to vote through a dropdown select. The problem is if the user has voted i need to be able to check req.user.username /or for not logged in users req.ip against a array of users that have voted allready ... but with asyncData i can get all the information before render eg name of chart, options to vote for , array of people who have voted .... but cant check against req.user.username (as asyncData dosent give me a req.user when request being made ) before render .... so if someone is logged in i have to wait for the page to render then check the store for the logged in user and then compare this to the voters and then disable the option to vote if they have voted. If i go the other way and wait till page loads and then send a axios request for the same information i do get access to the req.user ...... but it would be of far more benefit to be able to have this pre render.

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1818">#c1818</a>)</em></sub></div>