Skip to content

Commit

Permalink
feat(core): support POST in fetchFile
Browse files Browse the repository at this point in the history
  • Loading branch information
larsgw committed Jun 28, 2019
1 parent e66df63 commit ece8a2d
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/core/src/util/fetchFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ function parseOpts (opts = {}) {
reqOpts.allowRedirectHeaders = Object.keys(opts.headers)
}

if (opts.body) {
reqOpts.method = 'POST'
const isJson = typeof opts.body !== 'string'
reqOpts.body = isJson ? JSON.stringify(opts.body) : opts.body
reqOpts.headers['content-type'] = reqOpts.headers['content-type'] ||
isJson ? 'application/json' : 'text/plain'
}

return reqOpts
}

Expand Down

0 comments on commit ece8a2d

Please sign in to comment.