serialise-response
v0.0.4
Published
Serialise and deserialise HTML5 Responses
Downloads
379
Maintainers
Readme
serialise-response
Serialise and de-serialise HTML5 Responses
Made with ❤ at @outlandish
Install
npm install serialise-response --save
Import
ES6 Import (w/ Babel)
import serialiseResponse from 'serialise-response'
CommonJS Require
var serialiseResponse = require('serialise-response')
AMD
define(['serialiseResponse'], ...)
Script
<script src="/node_modules/serialise-response/dist/serialise-response.min.js"></script>
typeof window.serialiseResponse === 'object'
Usage
serialiseResponse(response[, toObject]) : String|Object
- response {Response} responseto serialise
- toObject {Boolean} serialise response to an object (default is string)
serialiseResponse.deserialise(response) : Promise<Response>
- response {String|Object} serialised response to deserialise
Function names are also made available in American English: serializeResponse
and serializeResponse.deserialize
Example
import serialiseResponse from 'serialise-response'
const serialisedResponse = serialiseResponse({ foo: 'bar' }))
// ...
const response = serialisedResponse.deserialise(serialisedResponse)
request.json().then((data) => {
console.log(data) //=> { foo: bar }
})
What about serialising a Request?
Check out the serialise-request
sibling module.
Contributing
All pull requests and issues welcome!
If you're not sure how, check out Kent C. Dodds' great video tutorials on egghead.io!