pusher / chatkit-client-js

JavaScript client SDK for Pusher Chatkit
https://pusher.com/chatkit
MIT License
90 stars 15 forks source link

Chatkit throws 'Field `id` is required.' error. #106

Closed heyypatrick closed 5 years ago

heyypatrick commented 5 years ago

I've been working on a chat system but now it throws an error "Field 'id' is required." It was working yesterday but upon checking now I encountered this error.

Here's my code.

const tokenProvider = new Chatkit.TokenProvider({
        url: "https://us1.pusherplatform.io/services/chatkit_token_provider/v1/ea217a79-e941-4537-bfcf- 
   b6cc1ab148f8/token"
    });

    const chatManager = new Chatkit.ChatManager({
        instanceLocator: "v1:us1:ea217a79-e941-4537-bfcf-b6cc1ab148f8",
        userId: 'Front-desk',
        tokenProvider: tokenProvider
    });

    var fd_chat_room_id =  Number($('input[name=chat_room_id]').val());

    chatManager
        .connect()
        .then(currentUser => {
            currentUser.joinRoom({
                roomId: fd_chat_room_id
            }).then(room => {
                console.log(room);
            });
        });

hp_chat

vivangkumar commented 5 years ago

Hi! What version of the client are you using?

heyypatrick commented 5 years ago

Hi! I'm currently using the latest version 1.0.2.

vivangkumar commented 5 years ago

@heyypatrick interesting. Could you please share a screenshot of the network tab as well please?

heyypatrick commented 5 years ago

I'm having an error at /users_by_ids end-point. chatkit_error

vivangkumar commented 5 years ago

Yeah, I think we've figured out what the issue is. Seems to be an issue with the way we published packages. We're fixing it as we speak. Hang in there! Apologies for the inconvenience.

heyypatrick commented 5 years ago

Thanks @vivangkumar !

vivangkumar commented 5 years ago

@heyypatrick are you sure you're running 1.0.2? How are you pulling in the dependency?

callum-oakley commented 5 years ago

Just a hunch in the meantime:

You've installed @pusher/chatkit-client and have version 1.0.2, but you also still have @pusher/chatkit and are importing/requiring that (which will be 0.8). If you import require @pusher/chatkit-client instead you'll be good (if I'm right, otherwise we'll keep investigating 😛).

heyypatrick commented 5 years ago

I'm pulling the dependency by using: <script src="https://unpkg.com/@pusher/chatkit"></script>

It is now in version 0.7.18 for the script @vivangkumar

heyypatrick commented 5 years ago

I'm importing it using the script tag @callum-oakley

callum-oakley commented 5 years ago

@heyypatrick we had to pull the 1.0 release from @pusher/chatkit because of people using the script tag without versioning it (which we erroneously did in our docs, so our fault!). The 1.0 release, and all future releases, is now at @pusher/chatkit-client. If you use

<script src="https://unpkg.com/@pusher/chatkit-client@1.0.2"></script>

then you'll get the latest version. Sorry about the confusion!

heyypatrick commented 5 years ago

Ohh I see. I understand. Thanks @callum-oakley and @vivangkumar :+1:

vivangkumar commented 5 years ago

Great! Thanks @heyypatrick and sorry for the confusion!

heyypatrick commented 5 years ago

Hi @vivangkumar i'm using the version 1.0.1 of the chatkit client. Is it available? Seems like not working for me anymore. I imported it using: <script src="https://unpkg.com/@pusher/chatkit@1.0.1/dist/web/chatkit.js"></script>

But the script is now on 404. Thanks!

vivangkumar commented 5 years ago

@heyypatrick We pulled that release and have a new version 1.0.2 released under chatkit-client. <script src="https://unpkg.com/@pusher/chatkit-client@1.0.2/dist/web/chatkit.js"></script>

heyypatrick commented 5 years ago

Ohh I see. Thank you @vivangkumar , again. :smiley:

vivangkumar commented 5 years ago

No worries :)