Spot the bug in the diagnostic wrapper

from AI-assisted debugging
Node 24 intermediate 6 min 3 issues to find

Find the failures in this generated diagnostic wrapper.

JavaScript
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

async function fetchProfile(url, token) {
  try {
    const response = await fetch(url, {
      headers: { authorization: `Bearer ${token}` },
    });
    return await response.json();
  } catch (error) {
    console.log("profile failure", { url, token, error });
    await delay(5000);
    return fetchProfile(url, token);
  }
}
Open in playground
Report an error