Skip to content

Commit 7f136cf

Browse files
committed
chore: 🔥 change error property name
1 parent 33ff89e commit 7f136cf

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ export default {
5050
// simple usage
5151
'vue-api-queries/nuxt',
5252
// With options
53-
['vue-api-queries/nuxt', { errorsKeyName: 'errors' }],
53+
['vue-api-queries/nuxt', { errorProperty: 'errors' }],
5454
'@nuxtjs/axios',
5555
],
56-
apiQueries: { errorsKeyName: 'errors' },
56+
apiQueries: { errorProperty: 'errors' },
5757
}
5858
```
5959

nuxt/templates/plugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import Vue from 'vue'
22
import VueApiQueries, { Validator, BaseProxy } from 'vue-api-queries'
33

4-
const errorsKey = '<%= options.errorsKeyName %>'
4+
const errorProperty = '<%= options.errorProperty %>'
55

66
export default function (ctx) {
77
Vue.use(VueApiQueries)
88
ctx.$errors = Validator
99
BaseProxy.$http = ctx.$axios
10-
BaseProxy.$errorsKey = errorsKey || 'errors'
10+
BaseProxy.$errorProperty = errorProperty || 'errors'
1111
// inject('queries', BaseProxy)
1212
}

src/core/BaseProxy.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class BaseProxy {
2424
public parameters: any | any[]
2525
public readonly endpoint: string
2626
public static $http: AxiosInstance | undefined
27-
public static $errorsKey = 'errors'
27+
public static $errorProperty = 'errors'
2828

2929
constructor(endpoint: string, parameters?: ParametersType) {
3030
this.endpoint = endpoint
@@ -36,8 +36,8 @@ class BaseProxy {
3636
return <AxiosInstance>BaseProxy.$http
3737
}
3838

39-
get $errorsKey() {
40-
return BaseProxy.$errorsKey
39+
get $errorProperty() {
40+
return BaseProxy.$errorProperty
4141
}
4242

4343
/**
@@ -201,7 +201,7 @@ class BaseProxy {
201201
const { data, status } = response
202202
if (status === UNPROCESSABLE_ENTITY) {
203203
const errors = {}
204-
Object.assign(errors, data[this.$errorsKey])
204+
Object.assign(errors, data[this.$errorProperty])
205205
this.onFail(errors)
206206
}
207207
reject(error)

0 commit comments

Comments
 (0)