title: How to access this in my services folder of NuxtJS
body: <p>Hello I learned NuxtJS in VueMastery and I think what they teach is really good. Where the pattern of getting data consists of async fetch, store and services.</p>
  
  <p><strong>page/index.vue</strong></p>
  
  <pre><code>&lt;template&gt;
    &lt;div&gt;&lt;/div&gt;
  &lt;/template&gt;
  
  &lt;script&gt;
  export default {
    mounted() {
      this.$myInjectedFunction("works in mounted");
    },
    async fetch({ store, app, req, env }) {
      await store.dispatch("scooby/getBanners", { page: 1 });
    }
  };
  &lt;/script&gt;
  
  </code></pre>
  
  <p><strong>store/scooby.js</strong></p>
  
  <pre><code>import ScoobyService from "@/services/ScoobyService.js";
  export const state = () =&gt; ({
    banners: []
  });
  export const mutations = {
    SET_BANNERS(state, banners) {
      state.banners = banners;
    }
  };
  export const actions = {
    getBanners({ commit }, payload) {
      this.$myInjectedFunction("accessible in actions");
      const type = payload.type || 1;
      const params = `?ad_type=${type}&amp;page=${payload.page}`;
      return ScoobyService.adBanner(params).then(response =&gt; {
        commit("SET_BANNERS", response.data);
      });
    }
  };
  </code></pre>
  
  <p><strong>services/scoobyService.js</strong></p>
  
  <pre><code>/* eslint-disable no-console */
  import { scoobyApiClient, scoobyRequestSetup } from "@/assets/js/axios.js";
  
  const apiModule = "scooby";
  
  const resources = {
    adBanner: `/v1/member/banners`
  };
  
  export default {
    adBanner(getParams) {
      // this.$myInjectedFunction("accessible in actions");
      const body = {};
      const resource = `${resources.adBanner}/${getParams}`;
      const [api, req] = scoobyRequestSetup(resource, body, apiModule);
  
      return process.server
        ? scoobyApiClient.get(api, req)
        : scoobyApiClient.post(api, req);
    }
  };
  </code></pre>
  
  <p><strong>plugins/combined-inject.js</strong></p>
  
  <pre><code>/* eslint-disable no-console */
  export default ({ app }, inject) =&gt; {
    inject("myInjectedFunction", string =&gt; console.log("That was easy!", string));
  };
  </code></pre>
  
  <p><strong>nuxt.config.js</strong></p>
  
  <pre><code>module.exports = {
    ...
      plugins: [
      "~/plugins/axios.js"
    ],
    ...
  }
  </code></pre>
  
  <p>The <strong>services/scoobyService.js</strong> can not access the <code>this</code> object but <strong>store/scooby.js</strong> can. How can I access the this object in <strong>services/scoobyService.js</strong></p>