twilio / twilio-chat-console-webapp.js

Web Console example app for Twilio Programmable Chat with working push messages
https://www.twilio.com/chat
Other
15 stars 9 forks source link

Cannot read property 'postFormData' of undefined #9

Open tansukhcodoffer opened 5 years ago

tansukhcodoffer commented 5 years ago

`

             var formData = new FormData();

            formData.append('file', $(this)[0].files[0]);

            for (var data of formData) {
                    console.log(data);
            }

            if (formData) {

                    chatClient.getChannelBySid(activeChannel.sid).then(function (channel) {

                            channel.sendMessage(formData);

                    });

            }

`

Uncaught (in promise) TypeError: Cannot read property 'postFormData' of undefined at t. (twilio-chat.min.js:127) at k (twilio-chat.min.js:204) at Generator._invoke (twilio-chat.min.js:204) at Generator.e.(anonymous function) [as next] (***twilio-chat/dist/twilio-chat.min.js:204:4546) at twilio-chat.min.js:127 at new Promise () at new t (twilio-chat.min.js:145) at p (twilio-chat.min.js:127) at t.value (twilio-chat.min.js:127) at t. (twilio-chat.min.js:127)

I am getting error shown above. Need help regarding this issue.

aleksandrsivanovs commented 5 years ago

it seems that something is wrong with: 1) client initialization or 2) file in form data or 3) error handling in our lib

can you provide more details on how you initialise client and does this file exist?

I've just tried it with the provided sample and it worked :)

tansukhcodoffer commented 5 years ago

Here is my code. Wherever i am trying to upload media then getting error which is attached image. Please look at your latest twilio-chat.min.js SDK.

var f = e.target.files[0]; if (f) { var r = new FileReader(); r.onload = function (e) { var contents = e.target.result; activeChannel.sendMessage({ contentType: f.type, media: contents, }).catch(function(e){ console.log(e.message); }); } r.readAsBinaryString(f); } image

1) Client initialization is okay. I have checked it. 2) The role permission is also okay for channel members.

I have tried all code which is mentioned on documentation but still getting error.

harvijivani8334 commented 5 years ago

Anyone got the solution for this issue?