Skip to content

Commit

Permalink
style
Browse files Browse the repository at this point in the history
  • Loading branch information
feross committed Apr 24, 2018
1 parent 83c57e1 commit 6c0f950
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ function simpleGet (opts, cb) {
if (opts.method) opts.method = opts.method.toUpperCase()

var body
if (opts.form) body = typeof opts.form === 'string' ? opts.form : querystring.stringify(opts.form)
if (opts.body) body = opts.json && !isStream(opts.body) ? JSON.stringify(opts.body) : opts.body

if (opts.json) opts.headers.accept = 'application/json'
if (opts.form) opts.headers['content-type'] = 'application/x-www-form-urlencoded'
delete opts.body
delete opts.form
if (opts.body) {
body = opts.json && !isStream(opts.body) ? JSON.stringify(opts.body) : opts.body
} else if (opts.form) {
body = typeof opts.form === 'string' ? opts.form : querystring.stringify(opts.form)
}
delete opts.body; delete opts.form

if (body) {
if (!opts.method) opts.method = 'POST'
Expand Down

0 comments on commit 6c0f950

Please sign in to comment.