JavaScript Code Reorder Medium +20 XP
Fetch API Pattern
Reorder to make a proper fetch call.
Click lines in the correct order
Available lines5 left
Your order
Click lines above to build your solution.
Show answer and explanation
Answer: async function getData(url) {
const response = await fetch(url);
const data = await response.json();
return data;
}
First declare the async function, then fetch, then parse JSON, then return.
Hint: You must fetch before you can parse the response.
What this challenge tests
Code Reorder in JavaScript: async, fetch.