Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting insufficient permission status #29

Closed
acerola1 opened this issue Dec 25, 2021 · 2 comments
Closed

Getting insufficient permission status #29

acerola1 opened this issue Dec 25, 2021 · 2 comments

Comments

@acerola1
Copy link

acerola1 commented Dec 25, 2021

I created a hook

import { doc } from "@firebase/firestore";
import { useFirestoreDocumentData } from "@react-query-firebase/firestore";
import { UseQueryResult } from "react-query";
import { db } from "../utils/firebase";

export interface User {
  displayName: string;
}
export const GET_USER = "GET_USER";

const useGetUser = (
  id: string,
  enabled: boolean
): UseQueryResult<User, unknown> => {
  const ref = doc(db, "users", id);
  return useFirestoreDocumentData([GET_USER, id], ref, undefined, { enabled });
};

export default useGetUser;

When I use this hook and I have insufficient permission because a security rule, I could not read this status out of the hook return values. The status is loading and the data is undefined. How can I get the security exception?

@ZeroPie
Copy link

ZeroPie commented Jan 8, 2022

When you use it on your component

const { error, data, isLoading } = useGetUser()

What does error contain?

@acerola1
Copy link
Author

acerola1 commented Jan 8, 2022

It is working fine. It was my bad, it eventually get the error.

error: FirebaseError: Missing or insufficient permissions.
    at index.esm2017.js:4327
    at ns (index.esm2017.js:4325)
    at to.onMessage (index.esm2017.js:11273)
    at index.esm2017.js:11227
    at index.esm2017.js:11250
    at index.esm2017.js:15093
    at index.esm2017.js:15126 

I was misled by the react-query retries.

@acerola1 acerola1 closed this as completed Jan 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants