https://github.com/acacode/http-helpers-serializy
helpers for http web clients for integration with serializy
https://github.com/acacode/http-helpers-serializy
Last synced: 9 days ago
JSON representation
helpers for http web clients for integration with serializy
- Host: GitHub
- URL: https://github.com/acacode/http-helpers-serializy
- Owner: acacode
- License: mit
- Created: 2019-08-01T08:14:00.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-07-17T21:47:48.000Z (almost 6 years ago)
- Last Synced: 2025-10-19T13:39:26.477Z (8 months ago)
- Language: JavaScript
- Homepage:
- Size: 71.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
Helpers for integration serializy with http web clients
[](./LICENSE)
[](https://www.npmjs.com/package/http-helpers-serializy)
[](https://travis-ci.org/acacode/http-helpers-serializy)
[](https://www.codefactor.io/repository/github/acacode/http-helpers-serializy/overview/master)
[](http://npm-stat.com/charts.html?package=http-helpers-serializy)
[](https://bundlephobia.com/result?p=http-helpers-serializy)
[](https://bundlephobia.com/result?p=http-helpers-serializy)
HTTP client helpers serializy
## 🚀 Installation
$ npm i -S http-helpers-serializy
# or using yarn
$ yarn add http-helpers-serializy
## 📚 Usage
```js
import {
deserializeRequestData,
serializeResponseData,
} from 'http-helpers-serializy'
import { field, model } from 'serializy'
const SerializyModel = model({
foo: field('Foo', 'any'),
})
const ErrorModel = model({
message: field(e => (e ? JSON.stringify(e) : '')),
})
const structure = { Foo: '12345' }
const method = 'get'
const url = 'https://api.com/my-data'
const { data } = deserializeRequestData(SerializyModel, structure, {
method,
url,
})
// ...
const { data, error } = serializeResponseData(SerializyModel, structure, {
method,
url,
isError: false,
errorModel: ErrorModel,
error: { message: 'bad response' },
})
```
## 📝 License
Licensed under the [MIT License](./LICENSE).