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

TypeError: (getBuffer, getHeaders) is not a function #530

Open
AntoineMaillard06 opened this issue Apr 17, 2022 · 4 comments
Open

TypeError: (getBuffer, getHeaders) is not a function #530

AntoineMaillard06 opened this issue Apr 17, 2022 · 4 comments

Comments

@AntoineMaillard06
Copy link

AntoineMaillard06 commented Apr 17, 2022

I'm using react, redux w/ typescript. In my component file here is the function where I'm trying to post my formed data with axios.

MyComponent.tsx

import React, { useState } from 'react';
import FormData from 'form-data';
import Axios from 'axios';

...

  const requestSubmit = () => {
    const form = new FormData();

    form.append('firstName', firstName);
    form.append('lastName', lastName);
    form.append('email', email);
    form.append('phone', phone);
    form.append('birthdate', birthdate);
    form.append('motivation', motivation);
    form.append('fileId', fileId);
    form.append('fileCert', fileCert);

    Axios.post('http://localhost:3001/request', form.getBuffer(), {
      headers: {
        ...form.getHeaders(),
      },
    })
      .then((res) => {
        console.log(res);
      }).catch((err) => {
        console.error(err);
      });
  };

...

image

Tested with form-data v3.0.0 and v4.0.0?

I tried editing all the class and types names directly in the npm module code because I thought it was a conflict with the JS FormData class but still was an issue.

Thanks in advance.

@netronicus
Copy link

I'm having the same problem :c

@duro
Copy link

duro commented May 12, 2022

I am also getting this error when using form-data in a React Native application.

@mcmurrym
Copy link

I'm pretty sure it is because react native implements their own https://github.com/facebook/react-native/blob/main/Libraries/Network/FormData.js and that one keeps getting used.

@EricForGithub
Copy link

I got this error too. Any idea how to solve this problem?

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

5 participants