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

Create reply with attachment failing: "(TypeError): form.getHeaders is not a function" #191

Closed
BakulTessell opened this issue Dec 13, 2021 · 2 comments · Fixed by #193
Closed

Comments

@BakulTessell
Copy link

Hi,

I am trying to update a ticket with an attachment but it's failing with the below error:

Unhandled Rejection (TypeError): form.getHeaders is not a function

utils.js:159 Uncaught (in promise) TypeError: form.getHeaders is not a function
    at makeRequest (utils.js:159)
    at Freshdesk.createReply (client.js:226)
    at uploadScreenshot (QuickTicket.jsx:211)

The payload is:

    {
      body: ReactDOMServer.renderToString(rDesc),
      from_email: user.email,
      attachments: [
        sStream
      ],
    };

I followed the instructions on https://www.npmjs.com/package/freshdesk-api to attach a file.
Am I missing something?

@BakulTessell
Copy link
Author

Found the issue.
When using this package in a browser, the FormData object doesn't have a getHeaders() method.
If the line #159 in utils.js is changed to:

options.headers["Content-Type"] = "multipart/form-datai";

Then this issue is resolved.

@arjunkomath @maxkoryukov ,
Is it possible t push this fix in the next update?

@arjunkomath
Copy link
Owner

Thanks for looking into the issue, I'll investigate this today, hopefully release a fix soon.

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

Successfully merging a pull request may close this issue.

2 participants