14 lines
349 B
TypeScript
14 lines
349 B
TypeScript
interface BuildHeadersParams {
|
|
token?: string;
|
|
contentType?: string;
|
|
}
|
|
|
|
export const buildHeaders = ({ token, contentType }: BuildHeadersParams = {}) => {
|
|
const headers: Record<string, string> = {};
|
|
|
|
if (token) headers['Authorization'] = `Bearer ${token}`;
|
|
if (contentType) headers['Content-Type'] = contentType;
|
|
|
|
return { headers };
|
|
};
|