Initial website was built base on the context

This commit is contained in:
StormRunner06106
2026-09-11 10:13:41 -07:00
parent 1e532f4c42
commit f80bceaa3c
31 changed files with 4832 additions and 1 deletions
+36
View File
@@ -0,0 +1,36 @@
const API_BASE = import.meta.env.VITE_API_BASE_URL ?? "";
async function request(path, options = {}) {
const response = await fetch(`${API_BASE}${path}`, {
...options,
headers: {
"Content-Type": "application/json",
...options.headers,
},
});
if (!response.ok) {
let detail = "Something went wrong. Please try again.";
try {
const body = await response.json();
detail = body.detail ?? detail;
} catch {
// Keep the friendly fallback when a proxy or server returns non-JSON.
}
throw new Error(detail);
}
return response.json();
}
export const getProfile = (signal) => request("/api/profile", { signal });
export const getExperience = (signal) => request("/api/experience", { signal });
export const getSkills = (signal) => request("/api/skills", { signal });
export const getPosts = (signal) => request("/api/posts", { signal });
export const getPost = (slug, signal) => request(`/api/posts/${slug}`, { signal });
export const sendContactMessage = (payload) =>
request("/api/contact", {
method: "POST",
body: JSON.stringify(payload),
});