-
Piotrek authored
Feat: Added functionality for correctly displaying all of the advanced metrics (just needs better styling now). Fix: Reworked some of the if statements to ternaries for better readability and conciseness.
Piotrek authoredFeat: Added functionality for correctly displaying all of the advanced metrics (just needs better styling now). Fix: Reworked some of the if statements to ternaries for better readability and conciseness.
pingAdvanced.ts 821 B
import {
collection,
getDocs,
limit,
query,
where,
type DocumentData
} from "firebase/firestore/lite"
import type data_advanced from "interfaces/data_advanced"
import type { PlasmoMessaging } from "@plasmohq/messaging"
import { db } from "~background"
async function queryAdvancedData(brandName: string) {
const brandsCollection = query(
collection(db, "companies"),
where("brand", "==", brandName),
limit(1)
)
let brandsData
const brandsSnapshot = await getDocs(brandsCollection)
brandsSnapshot.forEach((doc) => {
brandsData = doc.data()
console.log(brandsData)
})
return brandsData
}
const handler: PlasmoMessaging.MessageHandler = async (req, res) => {
const response = await queryAdvancedData(req.body.name)
res.send({
response
})
}
export default handler