socket.emit(
"/rolls/create",
{ cookie: cookies.loginCookie, price },
async (game: any) => {
setLoading(false);
if (game?.error) {
errorNotif(game?.error);
return;
}
const usernames = await async.map(game.playerIds, async (e: number) => {
const res = await fetch(
process.env.REACT_APP_URL + "/api" + `/users/username/${e}`
);
const data = await res.json();
console.log(data.name) // FETCHES PROPERLY
return data.name;
})
//STOPS HERE FOR SOME REASON?
game.usernames = usernames;
setRolls(game);
}
#Very weird issue, totally no idea what's wrong here
7 messages · Page 1 of 1 (latest)
emitting the event isn't enough
your code also needs to listen for that event
and the listener should run the function when it recieves that event
also, why is the emitter providing the callback?
usually it's the listener that subscribes to some events and knows what to do when those are emitted