oh btw, anyone know how to use wasteof’s socketios with only the ws library, or do i have to use socket.io-client to like use the wasteof sockets. actcually which one has a bigger files size since i want my package use the least amount of dependencies.

currently we’re at 1 dependency, since fetchapi is in node now 🎉

comments (single view)

is there some docs or examples or something?

// i wrote this entirely from memory so there may be some syntax errors

import { io } from 'socket.io-client'
let socket = io('https://api.wasteof.money', { transports: ['websocket'], auth: { token: "BOT_TOKEN"} })

socket.on('updateMessageCount', count => {
    // fetch messages
})

socket.on('message', chatMessage => {
    // do something with the chat message
})

How do I get the BOT_TOKEN part? Thanks!

// if you dont know what a fetch request is, this will be very hard to understand
await fetch(“https://api.wasteof.money/session“, {
    headers: {
        "Content-Type": "application/json"
    },
    body: JSON.stringify({ username: "USERNAME", password: "PASSWORD" }),
    method: “POST“,
})
.then(response=>response.json())
.then(data=>data.token || null)

I do know what a fetch request is (I just didn’t know if BOT_TOKEN was some special token i didn’t have). This is very helpful though. Thanks!

oh yeah, its just a user tokem

View all comments