Experiments with tRPC and Nuxt Server API
This commit is contained in:
27
pages/index.vue
Normal file
27
pages/index.vue
Normal file
@@ -0,0 +1,27 @@
|
||||
<script setup lang="ts">
|
||||
const { $trpc } = useNuxtApp();
|
||||
|
||||
const { data: hello } = await $trpc.hello.useQuery({ text: 'client' });
|
||||
|
||||
// Il typing sul risultato e' corretto, ma sul body no
|
||||
const { data: otherHello } = await useFetch('/api/test/HELLO', {
|
||||
method: 'post',
|
||||
body: {
|
||||
world: 'MONDO'
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<h1>Index Page</h1>
|
||||
<div>
|
||||
<p>RPC Client output: {{ hello }}</p>
|
||||
<p>Nuxt API output: {{ otherHello?.risultato }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user