DEV Community

Play Button Pause Button
Nick Parsons
Nick Parsons

Posted on • Edited on

Build a Fully Functional Messaging Platform in 30 Minutes

Learn how to build a fully functional messaging platform using Stream's Messaging API in under 30 minutes!

The build uses the Stream Chat React Components, Create React App, and a few other libraries to get up and running quickly. Enjoy! :)

Top comments (2)

Collapse
 
rishadomar profile image
Rishad Omar • Edited

Hi Nick, Do you have a link to the source in github?
I've copied the code from your video but getting an error on server with 'updateUser()':

    const token = serverSideClient.createToken(username);
    console.log('Token for ' + username, token);
    try {
        await serverSideClient.updateUser({
            id: username,
            name: username
        }, token);
    } catch (err) {
        res.status(500).send("Error encountered updating user")
    }
Enter fullscreen mode Exit fullscreen mode
(node:68217) UnhandledPromiseRejectionWarning: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
    at ServerResponse.setHeader (_http_outgoing.js:485:11)
    at ServerResponse.header (/home/rishad/projects/learn/group-messaging-demo/node_modules/express/lib/response.js:771:10)
    at ServerResponse.send (/home/rishad/projects/learn/group-messaging-demo/node_modules/express/lib/response.js:170:12)
    at /home/rishad/projects/learn/group-messaging-demo/server.js:38:19
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
(node:68217) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 6)
Enter fullscreen mode Exit fullscreen mode

Discovered that I didn't have permission to create a Chat. printing out the error message in server.js is a good idea:

    } catch (err) {
        console.log("Error encountered updating user", err)
Enter fullscreen mode Exit fullscreen mode

Now getting the error:

Both secret and user tokens are not set. Either client.setUser wasn't called or client.disconnect was called
    at TokenManager.getToken
Enter fullscreen mode Exit fullscreen mode
Collapse
 
saadmrb profile image
Saad Alem

What are the cons ?