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

Issue getting uid using getState from redux #57

Open
OyeMoeed opened this issue Dec 6, 2023 · 0 comments
Open

Issue getting uid using getState from redux #57

OyeMoeed opened this issue Dec 6, 2023 · 0 comments

Comments

@OyeMoeed
Copy link

OyeMoeed commented Dec 6, 2023

`export function fetchUsersData(uid, getPosts) {
return (dispatch, getState) => {
const found = getState().usersState.users.some(el => el.uid === uid);
if (!found) {
firebase
.firestore()
.collection('Users')
.doc(uid)
.get()
.then(snapshot => {
if (snapshot.exists) {
let user = snapshot.data();
user.uid = snapshot.id;

        dispatch({type: USERS_DATA_STATE_CHANGE, user});
      }
    });
  if (getPosts) {
    dispatch(fetchUsersFollowingPosts(uid));
  }
}

};
}

export function fetchUsersFollowingPosts(uid) {
return (dispatch, getState) => {
firebase
.firestore()
.collection('posts')
.doc(uid)
.collection('uploads')
.orderBy('creation', 'asc')
.get()
.then(snapshot => {
const uid = snapshot.docs[0].ref.path.split('/')[1];
const user = getState().usersState.users.find(el => el.uid === uid);

    let posts = snapshot.docs.map(doc => {
      const data = doc.data();
      const id = doc.id;
      return {id, ...data, user};
    });
    dispatch({type: USERS_POST_STATE_CHANGE, posts, uid});
  });

};
}`

ERROR TypeError: relativePath.split is not a function (it is undefined), js engine: hermes
can you guide me about this error?

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

1 participant