Error returned in executing first code example on "How to use promises" guide #478
-
I am getting an error in this page in the first code example when trying to fetch using the browser console as directed. The error is:
The final response of the fetch command is:
The error does not occur when adding the code to a web page. Does anyone else get this error? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
This is because const fetchPromise = fetch(
"https://developer.mozilla.org/en-US/docs/Learn/contributors.txt",
);
console.log(fetchPromise);
fetchPromise.then((response) => {
console.log(`Received response: ${response.status}`);
});
console.log("Started request…"); Alternatively, if you wanted to try the example in the page, specifically, you could put it in a HTML document and open it in your browser: <!DOCTYPE html>
<title>Run fetch</title>
<script>
const fetchPromise = fetch(
"https://mdn.github.io/learning-area/javascript/apis/fetching-data/can-store/products.json"
);
console.log(fetchPromise);
fetchPromise.then((response) => {
console.log(`Received response: ${response.status}`);
});
console.log("Started request…");
</script>
I think we may open a content issue to replace the URL in those examples (or check if |
Beta Was this translation helpful? Give feedback.
This is because
mdn.github.io
is not set in MDN's current CSP. You can give this a try in your console from any MDN page:Alternatively, if you wanted to try the example in the page, specifically, you could put it in a HTML document and open it in your browser: