index.js
function remakeBody (body, bodyType) {
  return blobUtil
    .base64StringToBlob(body)
    .then(function (blob) {
      switch (bodyType) {
        case BodyTypes.ARRAY_BUFFER:
          return blobUtil.blobToArrayBuffer(blob)
        case BodyTypes.BLOB:
          return blob
        case BodyTypes.FORM_DATA:
          throw new Error('Cannot make FormData from serialised Request')
        case BodyTypes.JSON:
          return blobToString(blob)
            .then(function (str) {
              return JSON.parse(str)
            })
        case BodyTypes.TEXT:
          return blobToString(blob)
        default:
          throw new Error('Unknown requested body type "' + bodyType + '"')
      }
    })
}
function remakeBody (body, bodyType) {
  return blobUtil
    .base64StringToBlob(body)
    .then(function (blob) {
      switch (bodyType) {
        case BodyTypes.ARRAY_BUFFER:
          return blobUtil.blobToArrayBuffer(blob)
        case BodyTypes.BLOB:
          return blob
        case BodyTypes.FORM_DATA:
          throw new Error('Cannot make FormData from serialised Request')
        case BodyTypes.JSON:
          return blobToString(blob)
            .then(function (str) {
              return JSON.parse(str)
            })
        case BodyTypes.TEXT:
          return blobToString(blob)
        default:
          throw new Error('Unknown requested body type "' + bodyType + '"')
      }
    })
}
function remakeBody ( body , bodyType ) { return blobUtil . base64StringToBlob ( body ) . then ( function ( blob ) { switch ( bodyType ) { case BodyTypes . ARRAY_BUFFER : return blobUtil . blobToArrayBuffer ( blob ) case BodyTypes . BLOB : return blob case BodyTypes . FORM_DATA : throw new Error ( 'Cannot make FormData from serialised Request' ) case BodyTypes . JSON : return blobToString ( blob ) . then ( function ( str ) { return JSON . parse ( str ) } ) case BodyTypes . TEXT : return blobToString ( blob ) default : throw new Error ( 'Unknown requested body type "' + bodyType + '"' ) } } ) }
Deserialise the body of a Request.
@param {String} body
@param {String} bodyType
@returns {Promise}
Deserialise the body of a Request .