18 lines
421 B
TypeScript
18 lines
421 B
TypeScript
export function getApiHeaders(
|
|
includeAuth: boolean = true
|
|
): Record<string, string> {
|
|
const headers: Record<string, string> = {};
|
|
|
|
if (includeAuth) {
|
|
const authSession = useAuthSession().value;
|
|
|
|
if (authSession != null) {
|
|
headers['authorization'] = `${authSession.type} ${authSession.id}`;
|
|
}
|
|
}
|
|
|
|
headers['content-type'] = 'application/json';
|
|
|
|
return headers;
|
|
}
|