Static GitHub Issues

[2407] Access middleware variables from pages

prev: Emoji-mart-vue component - document is not defined
next: How to update vue-template-compiler

I'm trying to use middleware output in pages without Vuex. It seems inject is not available here and none of following work.

My middleware:

export default function (context) {
     console.log('middle ware')
     return axios.get('http://localhost:3000/api/test').then((res) => {
          //none of these work:
          context.my_var = res.data 
          inject('my_var', res.data) 
          return ({my_var: res.data})      
 })

Any idea?

<!--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/c2091">#c2091</a>)</em></sub></div>