mirror of
https://github.com/ArthurDanjou/trpc-nuxt.git
synced 2026-02-05 14:47:58 +01:00
feat: replace ohmyfetch with ofetch
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { useClient, useClientHeaders, useAsyncQuery } from '#imports'
|
||||
import { useAsyncQuery, useClient, useClientHeaders } from '#imports'
|
||||
const client = useClient()
|
||||
const headers = useClientHeaders()
|
||||
const { data: todos, pending, error, refresh } = await useAsyncQuery(['getTodos'])
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { useRoute, useAsyncQuery } from '#imports'
|
||||
import { useAsyncQuery, useRoute } from '#imports'
|
||||
const route = useRoute()
|
||||
const { data: todo, pending, error } = await useAsyncQuery(['getTodo', Number(route.params.id)])
|
||||
</script>
|
||||
|
||||
@@ -29,7 +29,6 @@ export const router = trpc.router<Context>()
|
||||
.mutation('addTodo', {
|
||||
input: TodoShape,
|
||||
async resolve(req) {
|
||||
console.log(req.input)
|
||||
return await $fetch<Todo>(`${baseURL}/todos`, {
|
||||
method: 'POST',
|
||||
body: req.input,
|
||||
@@ -43,7 +42,7 @@ export async function createContext(event: H3Event) {
|
||||
|
||||
// This is just an example of something you'd might want to do in your ctx fn
|
||||
// const x = useCookies(event)
|
||||
console.log(event.req.headers)
|
||||
console.log(event.node.req.headers)
|
||||
|
||||
return {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user