(body: RequestBody)
| 24 | ; |
| 25 | |
| 26 | function convertRequestBody(body: RequestBody): Object { |
| 27 | if (typeof body === 'string') { |
| 28 | return {string: body}; |
| 29 | } |
| 30 | if (body instanceof FormData) { |
| 31 | return {formData: body.getParts()}; |
| 32 | } |
| 33 | if (body instanceof ArrayBuffer || ArrayBuffer.isView(body)) { |
| 34 | // $FlowFixMe: no way to assert that 'body' is indeed an ArrayBufferView |
| 35 | return {base64: binaryToBase64(body)}; |
| 36 | } |
| 37 | return body; |
| 38 | } |
| 39 | |
| 40 | module.exports = convertRequestBody; |
no test coverage detected
searching dependent graphs…