A worked example, rendered from real sample data. Sign in to run the tool on your own input.
// User dashboard
async function loadUser(id) {
const res = await fetch(`/api/users/${id}`);
if (!res.ok) {
throw new Error(`Failed: ${res.status}`);
}
/* parse and return */
const data = await res.json();
return data;
}
const user = await loadUser(42);
console.log(user);async function loadUser(id){const res=await fetch(`/api/users/${id}`);if(!res.ok){throw new Error(`Failed: ${res.status}`);}const data=await res.json();return data;}const user=await loadUser(42);console.log(user);
Compress JavaScript by stripping whitespace, comments, and redundant syntax. Part of the DevTools Surf developer suite. Browse more tools in the JavaScript collection.