fix(curriculum): Wrong code that previously passes fetch challenge now fails (#48423)

* challenge with different parameter returned from fetch now fails as expected

* added hardcoded object in test file and special condition in test-challenges

* Update curriculum/challenges/english/04-data-visualization/json-apis-and-ajax/get-json-with-the-javascript-fetch-method.md

remove hardcoded data and mock fetch

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* Update curriculum/test/test-challenges.js

test no longer needs to be skipped

Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>

* reset the pollyfill

Co-authored-by: kravmaguy <flex4lease@gmail.com>
Co-authored-by: Oliver Eyton-Williams <ojeytonwilliams@gmail.com>
This commit is contained in:
abe
2022-12-09 07:54:54 -05:00
committed by GitHub
parent 0a0be525b2
commit 8ba08fb5f6
@@ -38,6 +38,30 @@ Update the code to create and send a `GET` request to the freeCodeCamp Cat Photo
# --hints--
Your code should use the fetched data to replace the inner HTML
```js
const catData = "dummy data";
const ref = fetch;
fetch = () => Promise.resolve({ json: () => catData });
async () => {
try {
document.getElementById("getMessage").click();
await new Promise((resolve, reject) => setTimeout(() => resolve(), 250));
} catch (error) {
console.log(error);
} finally {
fetch = ref;
assert.equal(
document.getElementById("message").textContent,
JSON.stringify(catData)
);
}
};
```
Your code should make a `GET` request with `fetch`.
```js