Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FormData undefined is not a function #329

Open
cesar-medina-25 opened this issue Aug 2, 2021 · 0 comments
Open

FormData undefined is not a function #329

cesar-medina-25 opened this issue Aug 2, 2021 · 0 comments

Comments

@cesar-medina-25
Copy link

cesar-medina-25 commented Aug 2, 2021

Hello!! I'm doing some testing with MirageJS and React Native, but it is crashing using FormData in requests.
Specifically in the next block of code (pretender.js line 1569) added in this PR #320

if (body instanceof FormData) {
  body.forEach(function (value) {
    if (value instanceof File) {
          totalSize += value.size;
    }
    else {
          totalSize += value.length;
    }
  });
}

Using console log with body returns these values:

{"_parts": [["grant_type", "password"], ["username", "user@user.com"], ["password", "123456"]]}

Then the app returns an error because body doesn't have a forEach function but it is an instanceof FormData:

TypeError: undefined is not a function (near '...body.forEach...')
scheduleProgressEvent@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:131702:25

Versions:

Pretender: 3.4.6
Axios: 0.21.1
MirageJS: 0.1.41
React Native: 0.63.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant