balls
This commit is contained in:
18
lib/fetchData.ts
Normal file
18
lib/fetchData.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
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;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user