[Feature Request] Add support for Cloud Functions v2 #6543
-
Currently trying to call a v2 callable function with |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
Hi there! Did you see anything in the native logs? Just curious. Also, what versions are you on, etc etc. |
Beta Was this translation helpful? Give feedback.
-
The function code: import { FieldValue } from 'firebase-admin/firestore'
import { logger } from 'firebase-functions/v2'
import { CallableRequest, HttpsError, onCall } from 'firebase-functions/v2/https'
import { v4 as uuidv4 } from 'uuid'
const fn = onCall(async (request: CallableRequest) => {
const { data, auth } = request
// ? app check
// if (!context.app) {
// throw new https.HttpsError('failed-precondition', 'unauthorized request')
// }
// ? auth check
if (!auth) {
throw new HttpsError('unauthenticated', 'unauthenticated request')
}
const { uid } = auth
const { customer_id } = auth.token
const id = uuidv4()
const colRef = 'target_collection'
const docRef = colRef.doc(id)
await docRef
.create({
...data,
meta: {
customer_id,
created_at: FieldValue.serverTimestamp(),
created_by: uid,
id,
audience: [...new Set<string>([uid])]
}
})
.catch((error) => {
const error_id = uuidv4()
logger.error(new Error('v2 fn error'), error, { error_id })
throw new HttpsError('internal', { error_id })
})
return { id }
}) and call it in react native as |
Beta Was this translation helpful? Give feedback.
-
#6626 implements |
Beta Was this translation helpful? Give feedback.
#6626 implements
getCallableFromUrl(url)
and I'll merge it and release as soon as CI goes green