I have an index.js file where I: initialize my Express app instance include a router.js file that defines a POST endpoint create a Socket.IO object code as follows: At the POST endpoint in router.js, I want to use the Socket.IO object like this: But this gives me the error: How do I make the io object available to this router.post()
Tag: node.js
How can i check a JWT token is valid using an async function route with nodejs?
I am following the guide below to verify that only registered users can send requests to my backend nodejs server, my frontend is sending requests with an authorization header that contains a token and that part is working well. The nodejs backend should then check the token is valid before sending a response: https://www.tonyvu.co/posts/jwt-authentication-node-js The example shows i should add
Undefined when searching with Find Mongoose Express
I receive an array of products that I need to search for with Mongoose, so I use Find passing the _id of each product. But when going through the array and trying to search, I only receive the data of the first product, for the others I always receive undefined. This is my code: In my MongoDB database I have
Search for regex terms independent of symbol
So I have this string right here, it’s a registration number: 12.325.767/0001-90 And I want to create a regex when I type “23”, return for me the “2.3” or if I type “700”, return for me “7/00” or if I type “19”, return “1-9”. So, I want to get the number even if there is a symbol in the middle.
If I don’t choose a file and press the send button, I will get a popup but it’ll break any future popups
If I press Send ☞ without choosing a file, it’ll say “No file selected.” in a little Bootstrap warning alert but it seems to break all future alerts like file uploaded or file already exists on disk. If I make an error alert like file already on disk, it’ll work and won’t break future alerts (meaning it won’t stop alerts
ShouldI replace setTimeout with node schedule in nodejs
I want to stop players from entering a raffle starting from 11:55pm – 11:59pm every thursday, so I have to make sure the route for entering the raffle at this particular time is block. I decided to use node-schedule for every seconds to see what the result would look like, but I was able to access the route. I dont
Discord bot loading but commands are not working
I’m making my first Discord bot and I’m following this tutorial playlist here: https://www.youtube.com/watch?v=j_sD9udZnCk&list=PLbbLC0BLaGjpyzN1rg-gK4dUqbn8eJQq4&ab_channel=CodeLyon But for some reason my bot will load, say the load message, and even set its custom status but none of the commands are working. I have looked at many other forum posts and none are my problem so I’m very confused. I’m using Discord.js 14.3.0
how to find out online of streamer via http get request twitch
Hello everyone! I need to send http get request to twitch API. How it works: User inputs name of the streamer, my programm sends http get request to twitch API and the output need to be how much viewers right now on the twitch stream. my try: Answer I recommend that you use a package like axios to make your
How to perform user-input validation using if statements
I’m trying to perform user validation using if statements but on testing using post man, I keep on getting only the first return statement ‘Email is required ‘ even after adding a valid email address and also an invalid email address. I have attached the user model, user controller logic and a picture of postman’s response user schema model user.controller.js
How to store data with nodejs outside of the project folder?
I am using ExpressJs and i want to save my files outside of the project like this. im using this code for upload and its ok my files uploaded correctly but i can not show them in the app cause route will be like this http://localhost:8000/../../fileArchive/1661839542935/name.jpg nut when i set this to src of an image, the src doesnt show