feat(composables): add fetch helper function
extend useFetch with a helper that prepends `/api` to the url, as well as makes the default http method "GET"
This commit is contained in:
		
							parent
							
								
									1db9bdec9c
								
							
						
					
					
						commit
						3640c0db11
					
				
							
								
								
									
										11
									
								
								composables/useApiFetch.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								composables/useApiFetch.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,11 @@
 | 
			
		||||
import { UseFetchOptions } from "nuxt/app";
 | 
			
		||||
 | 
			
		||||
const useApiFetch = async (url: string, options?: any) => {
 | 
			
		||||
	const at = useCookie("rockfic_cookie", {default: undefined})
 | 
			
		||||
	return useFetch("/api" + url, {
 | 
			
		||||
		method: "get",
 | 
			
		||||
		...options,
 | 
			
		||||
	})
 | 
			
		||||
} 
 | 
			
		||||
 | 
			
		||||
export default useApiFetch
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user