ref: change auth setting in Login Screen

This commit is contained in:
Luis Felipe Cadavid 2024-09-24 17:35:35 -05:00
parent 9d31ea245c
commit 12c90ff120
26 changed files with 1149 additions and 99 deletions

View file

@ -3,11 +3,23 @@ import i18n from "@package/utils/language/i18n"
const BASE_URL = process.env.NEXT_PUBLIC_API_URL
/**
* Fetches data from a specified endpoint and returns a `ReturnService` object.
*
* @template T - The type of the data expected from the API response.
* @param {string} BASE_URL_MODULE - The base URL module to be appended to the base URL.
* @param {string} endpoint - The specific API endpoint to fetch data from.
* @param {RequestInit} [options={}] - Optional configuration for the fetch request.
* @returns {Promise<ReturnService<T>>} A promise that resolves to a `ReturnService` object containing the fetched data.
*
* @throws {Error} If the fetch request fails or the response is not ok.
*/
async function FetchData<T>(
BASE_URL_MODULE: string,
endpoint: string,
options: RequestInit = {}
): Promise<ReturnService<T>> {
const url = `${BASE_URL}${BASE_URL_MODULE}${endpoint}`
const text = i18n.t("errorProcessingAPI") as string
try {
@ -29,4 +41,4 @@ async function FetchData<T>(
}
}
export { FetchData }
export { FetchData }