mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
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:
+24
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user