Skip to content

Commit

Permalink
fix: use FetchError from ofetch again
Browse files Browse the repository at this point in the history
  • Loading branch information
johannschopplich committed Aug 25, 2023
1 parent 4aa0dff commit 0bcd9a9
Show file tree
Hide file tree
Showing 9 changed files with 242 additions and 244 deletions.
4 changes: 2 additions & 2 deletions docs/guide/faq-how-to-track-errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This ensures you can still track errors in your client-side code.
With the latter property `data`, you can access the **error response body** returned from your API:

```ts
import type { FetchError } from '#nuxt-api-party'
import type { FetchError } from 'ofetch'

// Log your API's error response
console.error('Error response body:', (error as FetchError).data)
Expand Down Expand Up @@ -57,7 +57,7 @@ watchEffect(() => {
### Usage with `$jsonPlaceholder`

```ts
import type { FetchError } from '#nuxt-api-party'
import type { FetchError } from 'ofetch'

function onSubmit() {
try {
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@
"dependencies": {
"@nuxt/kit": "^3.6.5",
"defu": "^6.1.2",
"ofetch": "^1.3.2",
"ofetch": "^1.3.3",
"ohash": "^1.1.3",
"pathe": "^1.1.1",
"scule": "^1.0.0",
"ufo": "^1.2.0"
"ufo": "^1.3.0"
},
"optionalDependencies": {
"openapi-typescript": "^5 || ^6"
Expand All @@ -63,12 +63,12 @@
"@antfu/eslint-config": "^0.41.0",
"@nuxt/module-builder": "^0.4.0",
"@nuxt/test-utils": "^3.6.5",
"@types/node": "^20.5.4",
"@types/node": "^20.5.6",
"bumpp": "^9.2.0",
"eslint": "^8.47.0",
"nuxt": "^3.6.5",
"nuxt-api-party": "workspace:*",
"typescript": "^5.1.6",
"typescript": "^5.2.2",
"vitest": "^0.33.0",
"vue-tsc": "^1.8.8"
}
Expand Down
2 changes: 1 addition & 1 deletion playground/pages/jsonPlaceholder.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import type { FetchError } from 'ofetch'
import type { JsonPlaceholderComment } from '../types'
import type { FetchError } from '#nuxt-api-party'
const route = useRoute()
Expand Down
3 changes: 1 addition & 2 deletions playground/pages/petStore.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import type { FetchError } from '#nuxt-api-party'
import type { FetchError } from 'ofetch'
import type { components } from '#nuxt-api-party/petStore'
type Pet = components['schemas']['Pet']
Expand Down Expand Up @@ -76,7 +76,6 @@ async function abandonGarfield() {
})
}
catch (error) {
const _error = error as FetchError
console.error(error as FetchError)
// Log the API response body
console.error('Error response body:', (error as FetchError).data)
Expand Down
Loading

0 comments on commit 0bcd9a9

Please sign in to comment.