
import { fetcher } from '@cloudron/pankow';
import { API_ORIGIN } from '../constants.js';

function create() {
  const accessToken = localStorage.token;

  return {
    async getApp(url, version) {
      let result;
      try {
          result = await fetcher.get(`${API_ORIGIN}/api/v1/community/app`, { access_token: accessToken, url, version });
      } catch (e) {
          return [e];
      }
      if (result.status !== 200) return [result];
      return [null, result.body];
    }
  };
}

export default {
  create,
};
