CodShot
JavaScript Public

Fetch Active Users

Fetches users from an API and returns only those who are active using async/await and ES6+ syntax.

#api, fetch, async-await
JavaScript
const fetchActiveUsers = async (url) => {
  try {
    const response = await fetch(url);
    if (!response.ok) {
      throw new Error(`HTTP error! status: ${response.status}`);
    }
    const users = await response.json();
    return users.filter(user => user.active);
  } catch (error) {
    console.error('Failed to fetch users:', error);
    return [];
  }
};

Snippet actions

Pluto
Pluto
Updated: 2026-09-07 12:26
Public snippets
0
Forks
CodShot AI Help
Ask about CodShot features, plans, workspace, AI limits, referrals, and public help topics.
Hi! I can help you understand how CodShot works. What would you like to know?
For account-specific or sensitive issues, please open a support ticket. Open support