%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home2/rezakur1/www/portfolio/portfolio-rezakurnia/src/lib/api/
Upload File :
Create Path :
Current File : /home2/rezakur1/www/portfolio/portfolio-rezakurnia/src/lib/api/client.ts

const BASE_URL =
  import.meta.env.PUBLIC_API_URL ||
  "https://api.rezakurnia.com";

type ApiResponse<T> = {
  status: string;
  data: T;
  message?: string;
};

export async function apiGet<T>(endpoint: string): Promise<ApiResponse<T>> {
  try {
    const res = await fetch(`${BASE_URL}${endpoint}`, {
      method: "GET",
      headers: {
        "Content-Type": "application/json",
      },
    });

    if (!res.ok) {
      throw new Error(`API Error: ${res.status}`);
    }

    return await res.json();
  } catch (error) {
    console.error("API GET ERROR:", error);
    throw error;
  }
}

Zerion Mini Shell 1.0