config for oauth

This commit is contained in:
h z
2024-12-04 14:06:30 +00:00
parent 321dea202d
commit 55ddd17bf0
10 changed files with 76 additions and 24 deletions

View File

@@ -19,7 +19,11 @@ export async function fetchWithCache(url, cacheKey = url, cacheExpiry = 60) {
}
try {
const fetchPromise = fetch(url)
const token = localStorage.getItem("accessToken");
const headers = {
...(token? {Authorization: `Bearer ${token}`} : {}),
}
const fetchPromise = fetch(url, {headers})
.then((response) => {
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);