@@ -10,7 +10,7 @@ This package helps you quickly to build requests for REST API. Move your logic a
1010classes. Keep your code clean and elegant.
1111
1212Wouldn't it be great if you could just use your back end to validate forms on the front end? This package provides a
13- ` BaseProxy ` class that does exactly that. It can post itself to a configured endpoint and manage errors. The class is
13+ ` BaseService ` class that does exactly that. It can post itself to a configured endpoint and manage errors. The class is
1414meant to be used with a Laravel back end, and it doesn't limit that you need only to work with laravel, Ruby on Rail,
1515NodeJs, ExpressJs, or any other languages.
1616
@@ -127,18 +127,18 @@ It will create `$errors` object inside components.
127127
1281281.Create ** proxies** folder or your prefer folder name for this
129129
130- ` ~/proxies/NewsProxy .js `
130+ ` ~/proxies/NewsService .js `
131131
132132``` js
133- import { BaseProxy } from ' vue-axios-http'
133+ import { BaseService } from ' vue-axios-http'
134134
135- class NewsProxy extends BaseProxy {
135+ class NewsService extends BaseService {
136136 constructor (parameters = {}) {
137137 super (' news' , parameters)
138138 }
139139}
140140
141- export default NewsProxy
141+ export default NewsService
142142```
143143
1441442.Store
@@ -157,19 +157,19 @@ actions.js
157157
158158``` js
159159import { ALL } from ' ./mutation-types'
160- import { NewsProxy } from ' ~/proxies'
160+ import { NewsService } from ' ~/proxies'
161161import { BaseTransformer , PaginationTransformer } from ' vue-axios-http'
162162import { pagination , notify } from ' ~/utils'
163163
164- const proxy = new NewsProxy ()
164+ const service = new NewsService ()
165165
166166const all = async ({ commit, dispatch }, payload = {}) => {
167167 const { fn } = payload
168168 if (typeof fn === ' function' ) {
169- await fn (proxy )
169+ await fn (service )
170170 }
171171 try {
172- const { data , meta } = await proxy .all ()
172+ const { data , meta } = await service .all ()
173173 const all = {
174174 items: BaseTransformer .fetchCollection (data),
175175 pagination: PaginationTransformer .fetch (meta),
@@ -247,8 +247,8 @@ export default {
247247 async asyncData ({ app, store }) {
248248 const { id = null } = app .$auth .user
249249 await store .dispatch (' news/all' , {
250- fn : (proxy ) => {
251- proxy
250+ fn : (service ) => {
251+ service
252252 .setParameters ({
253253 userId: id,
254254 include: [' categories' ],
@@ -267,8 +267,8 @@ export default {
267267 mounted () {
268268 const { id = null } = this .$auth .user
269269 this .$store .dispatch (' news/all' , {
270- fn : (proxy ) => {
271- proxy
270+ fn : (service ) => {
271+ service
272272 .setParameters ({
273273 userId: id,
274274 include: [' categories' ],
@@ -282,7 +282,7 @@ export default {
282282
283283You can set or remove any parameters you like.
284284
285- ## Proxy 's methods are available
285+ ## Service 's methods are available
286286
287287| Method | Description |
288288| ----------------------------------------------- | --------------------------- |
@@ -301,7 +301,7 @@ Set parameters with key/value.
301301#### Example
302302
303303``` js
304- const proxy = new ExampleProxy ()
304+ const service = new ExampleService ()
305305const parameters = {
306306 search: {
307307 first_name: ' Sek' ,
@@ -317,7 +317,7 @@ const parameters = {
317317 },
318318 category_id: 6 ,
319319}
320- const { data } = proxy .setParameters (parameters).all ()
320+ const { data } = service .setParameters (parameters).all ()
321321this .data = data
322322```
323323
@@ -334,8 +334,8 @@ if setParameter that value is empty or null it will remove that param for query
334334#### Example 1
335335
336336``` js
337- const proxy = new ExampleProxy ()
338- const { data } = await proxy .setParameter (' page' , 1 ).all ()
337+ const service = new ExampleService ()
338+ const { data } = await service .setParameter (' page' , 1 ).all ()
339339this .data = data
340340```
341341
@@ -350,9 +350,9 @@ Expected will be:
350350#### Example 2
351351
352352``` js
353- const proxy = new ExampleProxy ()
353+ const service = new ExampleService ()
354354const queryString = ' limit=10&page=1&search[name]=hello'
355- const { data } = await proxy .setParameter (queryString).all ()
355+ const { data } = await service .setParameter (queryString).all ()
356356this .data = data
357357```
358358
@@ -370,20 +370,20 @@ Expected will be:
370370
371371Be sure to use only once in ` mounted() ` or ` asyncData() ` and ` asyncData() ` is only available in ` NuxtJs `
372372
373- ## Use proxy in components
373+ ## Use service in components
374374
375375- news/\_ id.vue pages
376376
377377``` js
378- import { NewsProxy } from ' ~/proxies'
378+ import { NewsService } from ' ~/proxies'
379379
380- const proxy = new NewsProxy ()
380+ const service = new NewsService ()
381381
382382export default {
383383 methods: {
384384 async fetchNews (id ) {
385385 try {
386- const { data } = await proxy .find (id)
386+ const { data } = await service .find (id)
387387 this .detail = data
388388 } catch (e) {
389389 console .log (e)
0 commit comments