i use firebase cloudfunction for my ionic app but i need to change the method ( onRequest to onCall ) but i don't understand exactly what i need to change
This is my current firebase code:
import * as functions from 'firebase-functions'
import * as admin from 'firebase-admin'
const serviceAccount = require('../permissions.json')
const cors = require('cors')({ origin: true })
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: 'https://{'myUrl'}.firebaseio.com'
})
export const posts = functions.https.onRequest(async (request, response) => {
const docs = await admin.firestore().collection('posts').orderBy('date', 'desc').get()
cors(request, response, () => {})
response.json(
docs.docs.map((doc) => {
return {
postID: doc.id,
...doc.data()
}
})
)
})
If anyone knows how I can change my code to make it work, It's super important i need to fix it quickly. Thank you in advance