Help needed In API call from extension

I am building and extension with plasmo I have one csui where I have all my code. I want to sent a request to my server, after finding it I found that messaging can be used for that my structure look like |---contents/ | |--App.tsx |---background/ | |--messages/ | |--ping.ts I am sending api requests from ping.ts and using the below approach
sendToBackground({
name: "ping",
body: {
url: window.location.href
},
extensionId: "mgaocmjffbjkbljpagklhidgpiaaglbm"
}).then((e) => {
setData((o) => ({ ...o, ...e }))
})
sendToBackground({
name: "ping",
body: {
url: window.location.href
},
extensionId: "mgaocmjffbjkbljpagklhidgpiaaglbm"
}).then((e) => {
setData((o) => ({ ...o, ...e }))
})
now for this i have to send my extension id but this id will be diffrent if i build and install it in diffrent browser, how to overcome this issue? Please some one help me
3 Replies
filthytone
filthytone•12mo ago
you can use (globalThis.browser || globalThis.chrome).runtime.id to get it
Ayondip
AyondipOP•12mo ago
Thank you buddy, it solved my problem
YAGPDB.xyz
YAGPDB.xyz•12mo ago
Gave +1 Rep to @filthytone (current: #5 - 9)
Want results from more Discord servers?
Add your server