fix(composables): create default/empty values for nested options fields as fallbacks
This commit is contained in:
		
							parent
							
								
									80438ecacd
								
							
						
					
					
						commit
						5dac1d6492
					
				@ -3,12 +3,15 @@ import { UseFetchOptions } from "nuxt/app";
 | 
			
		||||
const useApiFetch = async (url: string, options?: any) => {
 | 
			
		||||
	const at = useCookie("rockfic_cookie", { default: undefined });
 | 
			
		||||
	const { token } = useAuth();
 | 
			
		||||
	let head = {
 | 
			
		||||
		...(options?.headers || {}),
 | 
			
		||||
	};
 | 
			
		||||
	if (token.value) {
 | 
			
		||||
		head.Authorization = token.value;
 | 
			
		||||
	}
 | 
			
		||||
	return useFetch("/api" + url, {
 | 
			
		||||
		method: "get",
 | 
			
		||||
		headers: {
 | 
			
		||||
			...(options?.headers || {}),
 | 
			
		||||
			Authorization: `Bearer ${token.value}`,
 | 
			
		||||
		},
 | 
			
		||||
		headers: head,
 | 
			
		||||
		...options,
 | 
			
		||||
	});
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user