How to send messages from content to background
I tried to do send a message to the background but it doesn't seem to be called and I don't have any error. Just nothing happen. Am I doing this right?
// in content.tsx
const resp = await sendToBackground({
name: "upload-from-url",
body: {
url: "https://superlink.com"
}
})
console.log("resp", resp)// in background/upload-from-url.ts
import type { PlasmoMessaging } from "@plasmohq/messaging"
const handler: PlasmoMessaging.MessageHandler = async (req, res) => {
const { url } = req.body
console.log(url)
res.send("hello world")
}
export default handler