import { Locale_URL, ENV } from '../app.config';
import { Get } from '../lib/request/method';

import { flatRecordKeys } from './tool';

let cache = null;

export default async function request(url?: string) {
  try {
    const { locales } = await Get(url ?? `${Locale_URL}/applet.${ENV}.json`, { notTransform: true, shareRequest: true });
    return cache = flatRecordKeys(locales), cache;
  } catch (error) {
    return null;
  }
}