9951 explained code solutions for 126 technologies


chrome-extensionHow to fetch data in background script


fetch('https://example.org/some')
.then(response => response.text())
.then(response => console.log(response))
.catch()ctrl + c
example.org/some

sample url to fetch data from

esponse.text()

let's assume we're fetching text data

console.log(response)

do something with response

catch()

intercept all possible errors, so it won't break execution