I am trying to develop a Chrome extension. Now background scripts are replaced by service workers in manifest v3. How can I make an http request in the service worker?
Use this in your service worker:
fetch('http://example.com/movies.json')
.then((response) => response.json())
.then((data) => console.log(data));
Don't forget to set proper permissions in the manifest file:
"host_permissions": [
"http://example.com/"
],
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With