Not able to print an API response in content script despite getting the response in network logs

Have a content script that, when a button is clicked, uses Plasmo's messaging framework to make an API request via a background script Everything works fine: the relevant data is sent, received by the API, and a good response is sent back from the API ('healthy'), but for some reason the background script is not passing the response back to our content script. When we log the response, it's an empty object. Images: 1. is the call to our background script from our content script 2. is the background script 3. is the empty object in our console logs 4. is the confirmed healthy response from our network logs Have tried a bunch of debugging to no avail. Thanks!
No description
No description
No description
No description
12 Replies
yummyfresh
yummyfreshOP•4mo ago
I also tried adding our extension ID and running the script in Main World and it doesn't work
Arcane
Arcane•4mo ago
@yummyfresh has reached level 1. GG!
m
m•4mo ago
@lab I am also having the same issue. Is there something I am missing in the messaging docs?
lab
lab•4mo ago
Hm is the cs in the main world? The code looks about right to me
m
m•4mo ago
yup I have set up the CSConfig to be in main world.
Arcane
Arcane•4mo ago
@Mesh has reached level 1. GG!
m
m•4mo ago
any guidance here, spent the last few days debugging this as well :/
yummyfresh
yummyfreshOP•4mo ago
hey @lab — does the content script need to be in main world for it to receive the api response from background? If yes, even when we test it as such it still shows the weird empty object that I put in the screenshots. any other possible issues / fixes?
filthytone
filthytone•4mo ago
You can’t send response because it’s not json serializable .. send the awaited response.json() instead
yummyfresh
yummyfreshOP•4mo ago
thank you @filthytone -- this worked
YAGPDB.xyz
YAGPDB.xyz•4mo ago
Gave +1 Rep to @filthytone (current: #5 - 20)
lab
lab•4mo ago
Oooh I didn't notice that lol xD
Want results from more Discord servers?
Add your server