2020-04-21a few seconds read (About 73 words)How to use async function as parameter in TypeScriptIssue #640 1234567891011121314151617async function useCache( collectionName: string, key: string, response: functions.Response<any>, fetch: () => Promise<any>): Promise<any> { const existing = await db.collection(collectionName).doc(key).get() if (existing.exists) { response.send(existing.data()) return } const object = await fetch() const json = Object.assign({}, object) await db.collection(collectionName).doc(key).set(json) response.send(object)} 123456789useCache( "books", key, response, async () => { const service = new Service() return await service.doSomething(key) })#javascript