[READ-ONLY] Mirror of https://github.com/danielroe/vuejs-de. vuejs-de.netlify.app/
0

Configure Feed

Select the types of activity you want to include in your feed.

vuejs-de / server / api / cats.get.ts
586 B 24 lines
1import { z } from 'zod' 2 3const cats = z.array(z.object({ 4 height: z.number(), 5 id: z.string(), 6 url: z.string(), 7 width: z.number(), 8 breeds: z.array(z.object({ 9 name: z.string(), 10 wikipedia_url: z.string().optional(), 11 temperament: z.string(), 12 description: z.string() 13 })).nonempty() 14})) 15 16export default defineCachedEventHandler(async () => { 17 const result = await $fetch('https://api.thecatapi.com/v1/images/search?limit=10&has_breeds=1', { 18 headers: { 19 'x-api-key': useRuntimeConfig().catApiToken 20 } 21 }) 22 23 return cats.parse(result) 24}, { swr: true })