faetch from api

This commit is contained in:
Ruidy 2024-04-27 03:18:35 +02:00
parent 1a35d1173f
commit 9cc1f83dc0
No known key found for this signature in database
GPG key ID: E00F51288CB857CC
3 changed files with 21 additions and 1 deletions

View file

@ -7,6 +7,7 @@
- [ ] deploy
- [ ] nuxt image
- [x] prettier and eslint
- [ ] transition
- [ ] pwa
- [ ] seo, robots.txt
- [ ] update the README

View file

@ -9,4 +9,11 @@ export default defineNuxtConfig({
autoprefixer: {},
},
},
runtimeConfig: {
// The private keys which are only available server-side
apiUrl: process.env.API_URL,
// Keys within public are also exposed client-side
public: {},
},
ssr: true,
});

View file

@ -1,3 +1,15 @@
<script setup lang="ts">
const { data, pending, error, refresh } = await useFetch(
"https://www.themealdb.com/api/json/v1/1/random.php",
);
</script>
<template>
<div>random</div>
<div>
<div v-if="pending">Loading</div>
<div v-else-if="error">Failed: {{ error }}</div>
<pre v-else>
{{ data?.meals?.[0] }}
</pre>
</div>
</template>