Code Editor
1 min
const fetchCake = async (id) => {
const response = await fetch(`https://api.cakes.com/${id}`, {
method: "GET",
headers: {
"Accept": "application/json"
}
});
if (!response.ok) {
throw new Error(`Request failed with status ${response.status}`);
}
return response.json();
};