title: Strapi v4: How to access context within a service
body: <p>When I create a custom controller in Strapi I get convenient access to a Context object where I can get the current user and use that user's data as I wish:</p>
  <pre><code>module.exports = createCoreController(&quot;api::event.event&quot;, ({ strapi }) =&gt; ({
    //Get logged in  users
    async me(ctx) {
      const user = ctx.state.user;
  
      if (!user) {
        return ctx.badRequest(null, [
          { messages: [{ id: &quot;No authorization header was found&quot; }] },
        ]);
      }
      const data = await strapi.entityService.findMany(&quot;api::event.event&quot;, {
        filters: {
          user: user.id,
        },
      });
  
      if (!data) {
        return ctx.notFound();
      }
  
      const sanitizedEntity = await sanitize.contentAPI.output(data);
  
      return { data: sanitizedEntity };
    },
  }));
  </code></pre>
  <p>However when I create a custom service by trying to extend the Core services, I don't seem to have the context object as above:</p>
  <pre><code>module.exports = createCoreService(&quot;api::event.event&quot;, ({ strapi }) =&gt; ({
    //https://docs.strapi.io/developer-docs/latest/development/backend-customization/services.html#extending-core-services
  
    async create(params) {
      console.log(&quot;inside event.js - create&quot;);
      console.log(&quot;params&quot;, params);
  
      console.log(&quot;params to save&quot;, params);
  
      // some logic here
      const result = await super.create(params);
      // some more logic
  
      return result;
    },
  
    async update(entityId, params) {
      params.data.user = entityId;
  
      // some logic here
      const result = await super.update(entityId, params);
      // some more logic
  
      return result;
    },
  }));
  </code></pre>
  <p>If possible I would like to access the context object because I would like to access the user info and get user id and add that id as the owner or creator of that entry.</p>
  <p>Is it possible and how does one do that???</p>