Skip to content

v0.8.0

Compare
Choose a tag to compare
@kiaking kiaking released this 31 Oct 11:04
· 68 commits to master since this release

New Features

Transform response data before persisting to the store.

Now you can transform response data by the new dataTransformer option.

This option will let you transform the response before persisting it to the store. Let's say your response from the server looks like below.

{
  ok: true,
  record: {
    id: 1,
    name: 'John Doe'
  }
}

You can use dataTransform property to specify how you want to transform the data. The whole Axios response will be passed as callback argument.

User.api().get('/api/users', {
  dataTransformer: (response) => {
    return response.data.record
  }
})

With the above config, the data inside record key will be inserted to the store.

It is very useful when you need to transform a given response to be handle by Vuex ORM. For instance, if you format your response with the JSON:API specs, you can transform your response with this callback.

Please check out the doc for more details.

Thanks so much to @guillaumebriday for this wonderful PR! 🎉