Skip to content

Commit

Permalink
Some code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
zellwk committed Sep 20, 2022
1 parent 0e3fe52 commit 4f01e68
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/handleResponse.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,10 @@ function getResponseType (type) {

async function parseResponse (response, options) {
// Parse formData into JavaScript object
// TODO: Create test for formData format
if (options.type === 'formData') {
let body = await response.text()
if (typeof URLSearchParams !== 'undefined') {
const query = new URLSearchParams(body)
body = Object.fromEntries(query)
} else {
const querystring = require('querystring')
body = querystring.parse(body)
}
const query = new URLSearchParams(body)
body = Object.fromEntries(query)

return createOutput({ response, body, options })
}
Expand Down

0 comments on commit 4f01e68

Please sign in to comment.