import type { TGetFromServerArgs } from "@web3r/flowerkit/net"; import { getFromServer } from "@web3r/flowerkit/net"; import { selectEmptyOptions } from "../config/constants"; import type { TOptionType } from "../config/types"; type TSelectOptionsResponse = { isSuccess?: boolean; data?: { options?: TOptionType[]; }; }; /** * Fetches options from a remote URL using a standardized response format. * Expects the response to contain `data.options` when successful. * @returns {Promise} */ export const getSelectOptionsFromUrl = async ( requestCfg: TGetFromServerArgs = {} ): Promise => { const resp = await getFromServer({ ...requestCfg, }); return resp.isSuccess ? resp.data?.options ?? selectEmptyOptions : selectEmptyOptions; };