Skip to content

acacode/kinka-serializy

Repository files navigation

kinka + serializy

⚡️ Integration serializy with kinka ⚡️

🚀 Installation

$ npm i -S kinka-serializy
# or using yarn
$ yarn add kinka-serializy

📚 Usage

import kinka from 'kinka'
import KinkaSerializy from 'kinka-serializy'


const api = kinka.create({
  baseURL: 'https://your-api.com',
  middlewares: [
    KinkaSerializy
  ]
})

// ...

const { data } = await api.get('/client/1234', {
  model: ClientModel
})

console.log(data) // your serialized client model

Also if you want to serialize error messages from server you need to:

const api = kinka.create({
  baseURL: 'https://your-api.com',
  middlewares: [
    KinkaSerializy({
      errorModel: YourPrettifiedErrorModel
    })
  ]
})

📝 License

Licensed under the MIT License.