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

docStore returns undefined #152

Open
NielAgi opened this issue Feb 29, 2024 · 1 comment
Open

docStore returns undefined #152

NielAgi opened this issue Feb 29, 2024 · 1 comment

Comments

@NielAgi
Copy link

NielAgi commented Feb 29, 2024

export const db = getFirestore();

const userData = docStore(db, `users/rNvXG7F...KyJw1`);
console.log($userData);
const userData = docStore(db, `users/${$user?.uid}`);
console.log($userData);

Both examples log undefined.
Has there been an update that broke docStore or am I just unbelievable stupid?

@akbor
Copy link

akbor commented Jun 7, 2024

docstore will initially return undefined as its fetching, so you'll have to do a if check.

<script>
const userData = docStore(db, `users/rNvXG7F...KyJw1`);
</script>

{#if $userData !== undefined}
{userData.ref}
{:else}
<p>Loading... </p>
{/if}

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