How do I forward an API request from inside a React component to the BGSW?

Hey all! I'm making an extension that currently has a single content script which loads up a small div using React into the DOM, where a user can enter and submit messages. These messages are sent to an external API, but as I've learned, you need to use the PlasmoMessaging API in order to proxy the request to the BGSW... My only question is, how exactly is that communication done? Can inner-components (.tsx files) easily utilize the chrome / Plasmo API, or do I need to use the base content script (the one that holds & renders my main React component) to utilize these things?
SimpleComplex
SimpleComplex•51d ago
FYI, thos isn't doable if you want to use something like Axios - have to use raw fetch, afaict. Also, I figured this out just fine. Will post example or just some more details when I'm not on my phone.
Arcane
Arcane•51d ago
@SimpleComplex has reached level 1. GG!
SimpleComplex
SimpleComplex•49d ago
So, no, you don't need to be in the base "content script" file when calling Chrome API / Plasmo API functions - you can be in one of the inner-containers that are rendered within the main content script.
Want results from more Discord servers?
Add your server
More Posts