Skip to main content
JavaScript Bug Hunt Hard +35 XP

Async Await Missing

This function should wait for data but returns a Promise instead.

JavaScriptFind the bug
1async function getData(url) {
2 const response = fetch(url);
3 const data = response.json();
4 return data;
5}
The bug is on line 2

Select the correct fix

Show answer and explanation

Answer: Add await before fetch(url) and response.json()

fetch() returns a Promise. Without await, response is a Promise object, not the actual response.

Hint: Async functions need await to pause execution.

What this challenge tests

Bug Hunt in JavaScript: async, promises, fetch.

Related challenges