@xtreamr/cla-request
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -6,2 +6,13 @@ # Change Log | ||
## [1.0.4](https://github.com/pacorampas/la_modules/compare/@xtreamr/cla-request@1.0.3...@xtreamr/cla-request@1.0.4) (2021-08-13) | ||
### Features | ||
* accept formData ([12ffd09](https://github.com/pacorampas/la_modules/commit/12ffd09bd7147ae4a4d321c491b35df3afb884e4)) | ||
## [1.0.3](https://github.com/pacorampas/la_modules/compare/@xtreamr/cla-request@1.0.2...@xtreamr/cla-request@1.0.3) (2021-08-10) | ||
@@ -8,0 +19,0 @@ |
{ | ||
"name": "@xtreamr/cla-request", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"main": "index.js", | ||
@@ -30,3 +30,3 @@ "module": "es/index.js", | ||
}, | ||
"gitHead": "05a2eeab62c43c2c3b51d5315b5f9c1e66648740" | ||
"gitHead": "a67d01b41d044934ceff9e34c872411a96437e2d" | ||
} |
@@ -21,3 +21,3 @@ # Install | ||
// - Options: same options as vanilla fetch: https://developer.mozilla.org/es/docs/Web/API/Fetch_API | ||
// with some changes. Body should be an object and it is using as default content type header: 'application/json'. | ||
// with some changes. Body should be an object and 'application/json' is used as default content type header. If you prefer use a formData pass a formData key that will be set as body internaly (you can use both at same time: body and formData) | ||
// Add two new options to cache responses: cache and refreshCache (to force refresh cache data). | ||
@@ -24,0 +24,0 @@ request.fetch(path, options) |
@@ -14,3 +14,4 @@ import qs from 'qs' | ||
query: any | undefined, | ||
body: any | undefined | ||
body: any | undefined, | ||
formData: any | undefined | ||
} | ||
@@ -24,3 +25,4 @@ | ||
query: undefined, | ||
body: undefined | ||
body: undefined, | ||
formData: undefined | ||
} | ||
@@ -56,9 +58,15 @@ | ||
} | ||
const { body, query, cache, refreshCache, ...rest } = mergedOptions | ||
const { body, query, cache, refreshCache, formData, ...rest } = mergedOptions | ||
let theBody = formData || (body && JSON.stringify(body)) || undefined | ||
const optionsFetch = { | ||
body: body && JSON.stringify(body), | ||
body: theBody, | ||
...rest, | ||
} | ||
// is set auto by browser with formData | ||
if (formData) { | ||
delete optionsFetch.headers['Content-Type'] | ||
} | ||
if (this.bearer) { | ||
@@ -65,0 +73,0 @@ optionsFetch.headers = { |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
232298
4096