No Response from sendToBackground()

Hi there, plasmo noob here. Trying to call a firebase function on the click of a button from a content-script. Read docs on using the messaging api with a background worker. Think I set it all up correctly but not getting any response at all from the sendToBackground() method. Here's some snippets.

// Adding the event listener to my new injected button to call generate
newButton.addEventListener("click", async () => {
        console.log("I have been clicked")

        const response = await sendToBackground({
          name: "generate"
        })

        console.log("Response " + response)
}


// background/test/generate.ts

import type { PlasmoMessaging } from "@plasmohq/messaging"
import { httpsCallable } from "firebase/functions"

import { functions } from "~firebase"

const handler: PlasmoMessaging.MessageHandler = async (req, res) => {
  const generateMessage = httpsCallable<any, any>(
    functions,
    "generateMessage"
  )

  console.log("Calling the method")

  const response = await generateMessage()

  console.log("Response " + JSON.stringify(response))

  res.send({
    response
  })
}

export default handler


Again, I don't see any logs, when I execute this. Any ideas what I messed up?
Was this page helpful?