I am currently facing an issue with my Chrome Extension. The extension performs a successful GET request, but when I try to replicate the same action in the Chrome Console or Snippets, I encounter errors. Here is a minimal example of the code I am using:
fetch(url, {
method: "GET"
}).then(response => response.text())
.then(html => console.log(html))
.catch(error => console.log(error))
However, when running this code outside of the extension environment, I receive the following errors:
TypeError: Failed to fetch
for the error and
Failed to load resource: net::ERR_FAILED
in Chrome's inline error marker
Although I have tried adjusting headers in my AWS Lambda function to potentially resolve any CORS issues, the problem persists. This leads me to believe that CORS might not be the root cause of the issue.
My requests do not seem to leave my machine as they are not visible in AWS CloudWatch. Even testing on a clean Chrome User profile yields the same results. To rule out any server-related problems, I have also tested examples from this source.
async function testGet() {
const response = await fetch('https://jsonplaceholder.typicode.com/posts')
console.log(await response.json())
}
async function testPost() {
let r = await fetch('https://jsonplaceholder.typicode.com/posts', {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
lockevn: 1
}),
})
console.log(await r.json())
}
testGet()
testPost()
When monitoring the network activity in Chrome's Network tab, the request appears to be stalled.
The explanation provided about the queueing and stalled states does not seem to offer a clear solution to my current predicament. Despite restarting my browser and ensuring no disk cache allocation problems, the issue persists. Any insight into resolving this matter would be greatly appreciated.