Put the lines of code in the correct order without indentation so that you get a getData function that takes a URL as an argument and returns the received data if the statusCode is from 200 inclusive to 209 inclusive. Otherwise, print an error message in the console with the text "Incorrect data".
Fetch API
Error processing
Report a typo
Reorder lines using drag or arrows. Adjust indentation with left buttons
.catch((error) => console.log(error.message));
.then((response) => {
} else {
.then((json) => console.log(json))
throw new Error("Incorrect server response");
})
return data;
}
if (response.status >= 200 && response.status <= 209) {
const data = response.json();
fetch("https://jsonplaceholder.typicode.com/users")
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.