Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parameterNames is ignored #49

Closed
bernhardh opened this issue Feb 25, 2019 · 3 comments
Closed

parameterNames is ignored #49

bernhardh opened this issue Feb 25, 2019 · 3 comments

Comments

@bernhardh
Copy link

The method parameterNames mentioned in the readme is ignored. I want to change the params to json:api specification (for use with https://github.com/spatie/laravel-json-api-paginate)

import { Model as BaseModel } from 'vue-api-query'

export default class Model extends BaseModel {

  // define a base url for a REST API
  baseURL () {
    return this.$http.defaults.baseURL
  }

  // Overwrite parameter names because of json:api spec
  parameterNames () {
    return {
      include: 'include',
      filter: 'filter',
      sort: 'sort',
      fields: 'fields',
      append: 'append',
      page: 'page[number]',
      limit: 'page[size]'
    }
  }

  // implement a default request method
  request (config) {
    return this.$http.request(config)
  }
}

Tried to console.log inside parameterNames and it never gets called (baseUrl and request get called)

@robsontenorio
Copy link
Owner

@Peter-Krebs can you help?

@robsontenorio
Copy link
Owner

@bernhardh Just tested your use case. And it works as expected. Make sure you have updated the package to latest version. Currently 1.4.1

yarn add vue-api-query

@bernhardh
Copy link
Author

Thank you. Now its working. With 1.3.x it wasn't working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants