Skip to content

Commit 8e1a67f

Browse files
committed
feat: custom open fetch by ofetch
1 parent abdcb30 commit 8e1a67f

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/utils/__tests__/fetch.spec.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { describe, expect, it } from 'vitest'
2+
import { createOpenFetch } from '../fetch'
3+
import type { paths } from '#/generated/api-schema'
4+
5+
describe('fetch', () => {
6+
it('should fill path correctly', async () => {
7+
const $fetch = createOpenFetch<paths>({
8+
baseURL: 'https://api.example.com',
9+
})
10+
11+
await $fetch('/auth/login', {
12+
method: 'POST',
13+
body: {
14+
15+
password: 'password',
16+
},
17+
})
18+
19+
await $fetch('/pets/{id}', {})
20+
})
21+
})

0 commit comments

Comments
 (0)