I’m using Stripe extension for Firebase with firebase functions. Since I refactored a bit my code for firebase v9 modular SDK, I’m getting the following console error with my Stripe createPortalLink() function:
JavaScript
x
3
1
Uncaught (in promise) TypeError: _firebase__WEBPACK_IMPORTED_MODULE_2__.default.functions is not a function
2
at createPortalLink (Subscription.js:99:1)
3
Here is my function:
JavaScript
1
12
12
1
async function createPortalLink() {
2
const functionRef = app
3
.functions("europe-west1")
4
.httpsCallable("ext-firestore-stripe-payments-createPortalLink");
5
6
const { data } = await functionRef({
7
returnUrl: `${window.location.origin}/dashboard-pro/abonnement/`,
8
locale: "auto",
9
});
10
window.location.assign(data.url);
11
}
12
Can anyone please advise?
Thanks
Advertisement
Answer
You need to use the getFunctions()
and httpsCallable()
functions in the new Modular SDK as shown below:
JavaScript
1
15
15
1
import { getFunctions, httpsCallable } from "firebase/functions";
2
3
// after initializing Firebase
4
const functions = getFunctions();
5
6
const functionRef = httpsCallable(functions, 'ext-firestore-stripe-payments-createPortalLink');
7
8
functionRef({
9
returnUrl: `${window.location.origin}/dashboard-pro/abonnement/`,
10
locale: "auto",
11
})
12
.then((result) => {
13
const data = result.data;
14
});
15
Checkout the documentation for more details.