Skip to content

Error returned in executing first code example on "How to use promises" guide #478

Answered by bsmth
authentictech asked this question in Content
Discussion options

You must be logged in to vote

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:

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"
  );

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@authentictech
Comment options

@bsmth
Comment options

@wbamberg
Comment options

Answer selected by authentictech
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants