Last active
March 18, 2021 15:54
-
-
Save acoyfellow/90038acd1a9d6c25ceb84c7d532830b1 to your computer and use it in GitHub Desktop.
SvelteKit server route example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { firebase } from "$services/firebaseAdmin"; | |
export const get = async (req, context) => { | |
const globalRef = firebase.firestore().collection('global'); | |
let data = { | |
now: Date.now() | |
}; | |
const snapshot = await globalRef.get(); | |
snapshot.forEach(doc => { | |
data[doc.id] = doc.data(); | |
}); | |
return { | |
body: data, | |
status: 200 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment