I am creating a REST API with express, folowing are my architecture,a router is calling a controller.but I got this error, please help me /////// EmailLogin.js middleware Handler I’m trying to call it in my router, like this: /////// Router.js /////// App.js What could I do ? is it possible to get a Promise Result in the Router as a
Tag: node.js
socket.io emitting to all clients works, but emitting to room doesn’t work
When I try io.emit(), the message gets emitted to everyone but when I try io.to(room).emit(), the message doesn’t get emitted (In the 3rd last line of the code). I manually checked the sockets in the room, and all are present in the room correctly. But the message never gets transmitted. Answer I was able to fix it using socket.in(gameID).emit(“new user”,
Looping through an array and run a Jest test for each element does not work
I have a very large array of JSON objects. I need to run Jest tests on each individual element. I tried iterating through the array first and then write the tests in the loop as such: However with this code Jest complains that ” Your test suite must contain at least one test.” Do I have to loop over this
How can I upgrade to Discord.js V13?
Im using Discord.js V13 and when i try to run the bot i get this error everytime. Main File: The error: The solution here is that i can`t deconstruct the library from itself, and my mistake is that i needed to put only the intents that my bot needs. My solution: Answer You cannot deconstruct the library from itself. Either
Discord.js music bot hosted on heroku crashes after couple minutes
I have a discord bot hosted on heroku which among it’s other functionalities, also provides members to listen to music (much like the famous Rythm bot). However, every time I play a song, the bot crashes and restarts itself after 7-10 of playing songs. This only seems to happen when I’m playing music. Other than that, the bot seems to
countDocuments() is not working in api call
I am trying to get a count of products using api calls but in postman its keep loading without async and await also its not working I try to catch the error and i got this error in postman code to catch error: Answer I think in Mongoose operations you want to either await or provide a callback, but not
How do I use the pipeline from stream-json to write to file, in nodeJs?
I’m trying to use stream-json to read a zip, unzip it, and then write it to file. I don’t think I understand how to use the library. Based on the link above, they have this example: However I don’t want to count anything, I just want to write to file. Here is what I have that works: However I can’t
Cannot read properties of undefined (reading ‘classList’)
I’m following a tutorial for making BattleShip in javascript and html but i get an error : This is the tutorial: https://youtu.be/U64vIhh0TyM The error happens randomly sometimes, it’s been 5 days since this error occured and I can’t understand how to fix this. I hope that someone can find a solution soon. Answer The issue is that within isTaken the
Uncaught (in promise) SyntaxError: Unexpected end of JSON input error
This is simply add to cart function. Also means insert field to database. All is fine when it comes to adding to the database, however there is this error everytime I click add to cart(But still adds to database though). Here is my fetch code, leading to calling my controller. I’m not sure what json data is being returned here,
How to change this message to an code block message?
I want to change this part into a code block message I tried but it’s not working Here’s the full code Answer Since codeblocks have to be made with tripple `, you can just add them to the beginning and end like you normally do but escape them with a backslash so your normal string template doesnt end early: