Socket
Socket
Sign inDemoInstall

http-helpers-serializy

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    http-helpers-serializy

helpers for http web clients for integration with serializy


Version published
Weekly downloads
4
Maintainers
1
Install size
15.5 kB
Created
Weekly downloads
 

Changelog

Source

0.0.1

Added

  • Created project
  • Added deserializeRequestData(), serializeResponseData() helpers

Readme

Source

Helpers for integration serializy with http web clients

HTTP client helpers serializy

🚀 Installation

$ npm i -S http-helpers-serializy
# or using yarn
$ yarn add http-helpers-serializy

📚 Usage


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.

Keywords

FAQs

Last updated on 01 Aug 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc