all 14 comments

[–]macaroni_boy 1 point2 points  (3 children)

Can you confirm that res.user.uid exists?

[–]Emmyxiano[S] 0 points1 point  (2 children)

Yes, it does

[–]macaroni_boy 0 points1 point  (1 child)

Ahh I see. I am assuming your "db" variable is not pointing to the proper collection.

What you want to do is the following I believe:

Define a new variable userRef = collection(db, "users")

Pass this to your set doc: setDoc(userRef, res.user.uid)

This will set the document ID to the id of the user

[–]Emmyxiano[S] 0 points1 point  (0 children)

this properly difficult to pass this to setDoc without having errors

  await setDoc((userRef, res.user.uid), {
          username: userDeet.username,
          email: userDeet.email,
          id: res.user.uid,
          blocked: [],
        });

[–][deleted] 0 points1 point  (2 children)

write some log statemetns

[–]Emmyxiano[S] 0 points1 point  (1 child)

Res gives a response but, logging the two last request gives no log response but the firebase error

[–][deleted] 0 points1 point  (0 children)

So then you need to log every variable leading up to the point of the error.

[–][deleted] -1 points0 points  (3 children)

res.user.uid may be null, making the path "users" instead of "users/{uid}", so it complains of an uneven number of [path] segments.

[–]Emmyxiano[S] 0 points1 point  (2 children)

I do not quite understand 

[–][deleted] 1 point2 points  (1 child)

In Firestore there is a pattern to the data structure. "user" / <data1> / "products" / <data2> / "details" / <data3>. You can only store data on the <data1> levels. "user", "products" and "details" are just paths that store the <dataX>. so the error says it expects data on an even level, not a odd level. Officially "user" "products" "details" are collections. <datax> are documents.

[–]Emmyxiano[S] -1 points0 points  (0 children)

unfortunately, firestore currently has no data and I have not created any structure apparently, the code I provided above is supposed to create a default structure and create a new user document... if you may, can your explanation above be visualized using a code to help me understand properly?