cognee/cognee-frontend/src/utils/fetch.ts
Boris e1a0b55a21
feat: user authentication in routes (#133)
* feat: require logged in user in routes
2024-09-08 21:12:49 +02:00

12 lines
381 B
TypeScript

import handleServerErrors from './handleServerErrors';
export default function fetch(url: string, options: RequestInit = {}): Promise<Response> {
return global.fetch('http://127.0.0.1:8000/api' + url, {
...options,
headers: {
...options.headers,
'Authorization': `Bearer ${localStorage.getItem('access_token')}`,
},
})
.then(handleServerErrors);
}