@@ -296,6 +296,52 @@ export default class Model extends BaseModel {
296
296
}
297
297
```
298
298
299
+ ## Configuring Query Parameters Parser
300
+
301
+ See the [ API reference] ( /api/model-options#stringifyOptions ) and [ qs] ( https://github.com/ljharb/qs#stringifying )
302
+
303
+ We may also need to configure the parser to match our needs. By default, it is configured to match
304
+ ` spatie/laravel-query-builder ` , which uses ` comma ` array format.
305
+
306
+ If we want, for example, to change this behaviour to ` indices ` , we can configure the stringify options of ` qs `
307
+ by overriding the ` stringifyOptions ` method.
308
+
309
+ We can globally configure this in the [ Base Model] ( /configuration#creating-a-base-model ) :
310
+
311
+ ``` js{}[~/models/Model.js]
312
+ import { Model as BaseModel } from 'vue-api-query'
313
+
314
+ export default class Model extends BaseModel {
315
+
316
+ // Define a base url for a REST API
317
+ baseURL() {
318
+ return 'http://my-api.com'
319
+ }
320
+
321
+ // Implement a default request method
322
+ request(config) {
323
+ return this.$http.request(config)
324
+ }
325
+
326
+ // Override default query parameter names
327
+ parameterNames() {
328
+ const defaultParams = super.parameterNames()
329
+ const customParams = {
330
+ include: 'include_custom'
331
+ }
332
+
333
+ return { ...defaultParams, ...customParams }
334
+ }
335
+
336
+ // Configure qs
337
+ stringifyOptions() {
338
+ return {
339
+ arrayFormat: 'indices'
340
+ }
341
+ }
342
+ }
343
+ ```
344
+
299
345
## Configuring FormData
300
346
301
347
See the [ API reference] ( /api/model-options#formdata ) and [ object-to-formdata] ( https://github.com/therealparmesh/object-to-formdata#usage )
@@ -331,6 +377,13 @@ export default class Model extends BaseModel {
331
377
return { ...defaultParams, ...customParams }
332
378
}
333
379
380
+ // Configure qs
381
+ stringifyOptions() {
382
+ return {
383
+ arrayFormat: 'indices'
384
+ }
385
+ }
386
+
334
387
// Configure object-to-formadata
335
388
formData() {
336
389
return {
0 commit comments