wet-aquaW
Refine3y ago
40 replies
wet-aqua

AuthProvider triggeres many times getIdentity()

Hello, i'm using Strapi as my backend and I get a lots of API calls that uses method getIdentity() from authProvider.

 getIdentity: async () => {
    const token = localStorage.getItem(TOKEN_KEY);
    if (!token) {
      return null;
    }

    const { data, status } = await strapiAuthHelper.me(token, {
      meta: {
        populate: "*",
      },
    });
    if (status === 200) {
      // console.log(data);
      const { id, username, email, name, avatar, role } = data;
      return {
        id,
        username: username,
        name: name,
        email,
        avatar,
        role,
      };
    }

    return null;
  },



How to fix it?
Was this page helpful?