-
Notifications
You must be signed in to change notification settings - Fork 33
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
"self" is not defined when trying to use getfunctions/httpscallable API from firebase #100
Comments
Hey @dahburj, I haven't used the Client JS SDK in SvelteKit yet, but I believe you need to use it after checking that your are in a Can you share the reason you closed this Issue? |
I closed it because I got it to work within half an hour of posting the issue; the steps you mention was my OG game plan, however, let's just say it was a lot easier to plan than to execute😂.. But I finally found a way to get to import into the client side without the ton of errors I kept hitting. For any/all interested; I got it to work by using the router=browser variable in each of the functions, and; more importantly, to get it to run AND build without errors I had to import the firebase modules at the beginning of each/every function. if (router) {
const { getFunctions, httpsCallable } = await import("firebase/functions");
const functionsN = getFunctions();
await signUpWithEmailPassword(signupEmail, signupPassword);
const fCreateUser = httpsCallable(functionsN, "createUser");
await fCreateUser({ name: userFullName })
.then(async (result) => {
console.log(result);
const data = result.data;
console.log(data);
notificationMessage.set({
message: "Welcome back!",
type: "toast--link",
});
disableAction = false;
await goto("/dashboard");
})
.catch(function (error) {
console.log(error);
});
} P.S. I reached many-a similar problem trying to import firestore, and as my process went auth, functions, firestore, I felt defeated and settled on writing out my store middleware as a serious of firebase https functions, it works fine and I feel as though with bundling and caching maybe it won't be that bad, nonetheless, any advice/input you may have on the matter will be appreciated greatly🙋🏻♂️ |
I will probably write a guide on Firebase with SSR tools once I go through the motions of getting it to work in my own apps. I currently only have the new |
That sounds amazing, I feel as though I came close to the same thing but my experience with svelte-kit started when I found this adapter (in all seriousness twas a God send). My train of thought was to convert my datastore functions (now in the server running as httpscallable and using the firebase-admin@exp) into something along the lines of data bundles , setting each's timeout/cache accordingly and also a nice endpoint, but like I said, my experience with svelte-kit is pretty much nil; plus, I cant say I was/am too keen on diving into it because of the fact that using that method would entail changing up the "rewrites" in firebase.json and I'm not tring messing with the beauty of what your adapter does at this point in my development road map .😂 Do let me know when/if you decide to share those Sveltekit Endpoints! |
I will add examples to the docs as I resolve the issues - #101 |
Describe the bug
Well I don't if it's a bug or if I'm doing something wrong, but I keep getting all these crazy errors and build fails when I try to use/import firebase functions from any client side script. I have a multitude of Firebase Functions (besides the svelte kit one) that I'd like to utilize, but I have no idea how, any help would be greatly appreciated.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A build success message and the ability to use firebase's httpscallable API on some client rendered scripts, like for signup/login
Screenshots
Additional context
Error message below:
Adapter configuration:
{"firebaseJson":"firebase.json","sourceRewriteMatch":"**"}
Writing Cloud Function server assets to:
functions/sveltekit
Erasing static asset dir before processing:
public
Writing client application to:
public
Prerendering static pages to:
public
The text was updated successfully, but these errors were encountered: