Put the lines of code in the correct order with indentation so that you get a getData function that takes as an argument the URL to be accessed and prints to the console the data received using the fetch() request in the function. Print the error message in the console if the request fails.
Fetch API
.then/.catch methods
Report a typo
Reorder lines using drag or arrows. Adjust indentation with left buttons
function getData(url){
}
.then((response) => response.json())
fetch(url)
.then((json) => console.log(json))
.catch((error) => console.log(error.message))
___
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.