Files
ember-market-frontend/lib/fetchData.ts
2025-02-07 04:43:47 +00:00

18 lines
454 B
TypeScript

export const fetchData = async (url: string, authToken: string) => {
try {
const response = await fetch(url, {
headers: {
Authorization: `Bearer ${authToken}`,
},
credentials: "include",
});
if (!response.ok) throw new Error("Failed to fetch data");
return await response.json();
} catch (error) {
console.error("Error fetching data:", error);
throw error;
}
};