sacred-roseS
Refine15mo ago
9 replies
sacred-rose

How to get logged user ID from data provider?

I have a custom data provider. On the create function, I want to pass the logged user ID to the body of every create request. How can i do this?

This is my create function on Data provider

create: async ({ resource, variables, meta }) => {
  const url = `${apiUrl}/${resource}`;

  const { headers, method } = meta ?? {};
  const requestMethod = (method as MethodTypesWithBody) ?? "post";

  const { data } = await httpClient[requestMethod](url, variables, {
    headers,
  });

  return {
    data,
  };
},
Was this page helpful?