Skip to content

Commit

Permalink
Check for FormData before checking for object when preparing body (#249)
Browse files Browse the repository at this point in the history
* Check for FormData before checking for object when preparing body

* Add todo

* Cleanup
  • Loading branch information
sbichenko authored Apr 21, 2020
1 parent 335f505 commit f7cc214
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,8 @@ Todos
- [ ] make code editor plugin/package/extension that adds GraphQL syntax highlighting for `useQuery` and `useMutation` 😊
- [ ] add React Native test suite
[1]: https://github.com/ava/use-http/issues/new?title=[Feature%20Request]%20YOUR_FEATURE_NAME
[2]: https://github.com/ava/use-http/issues/93#issuecomment-600896722
[3]: https://github.com/ava/use-http/raw/master/public/dog.png
Expand Down
4 changes: 3 additions & 1 deletion src/doFetchArgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ export default async function doFetchArgs<TData = any>(
const url = `${initialURL}${path}${route}`

const body = ((): BodyInit | null => {
if (isBodyObject(routeOrBody)) return JSON.stringify(routeOrBody)
// FormData instanceof check should go first, because React Native's FormData implementation
// is indistinguishable from plain object when using isBodyObject check
if (routeOrBody instanceof FormData) return routeOrBody
if (isBodyObject(routeOrBody)) return JSON.stringify(routeOrBody)
if (
!isServer &&
((bodyAs2ndParam as any) instanceof FormData ||
Expand Down

0 comments on commit f7cc214

Please sign in to comment.