/*!
 * Copyright (c) 2024 Eclipse Foundation, Inc.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v. 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0.
 *
 * SPDX-License-Identifier: EPL-2.0
 */

import 'isomorphic-fetch';
import { transformSnakeToCamel } from './utils';

const apiBasePath = 'https://api.eclipse.org/working-groups';

export const getWorkingGroups = async () => {
  try {
    const response = await fetch(apiBasePath);
    const data = await response.json();
    
    const workingGroups = data.map(transformSnakeToCamel);

    return [workingGroups, null];
  } catch (error) {
    return [null, error];
  }
}

