Skip to content

FormData undefined is not a function #329

@cesar-medina-25

Description

@cesar-medina-25

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions