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
Tag: express
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
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
Get user data in request.user using express and typescript
I’m trying to create a middleware to ensure the user is admin, but when I print request.customer, the result is undefined. This is what I’m doing: request.customer returns this: Property ‘customer’ does not exist on type ‘Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>’ So I declared the express namespace by adding the customer id, like this: I have no errors but
axios.spread() cache my API whereas axios.get() does not
I’m facing a weird situation where I need to call a bunch of my CMS API routes from my server in order to use their response.data into an object that will then be passed to my client side. This is the code that caches my data: meaning that when I change a field on my CMS, that data that is
How to send a sorted result from my MongoDB database by clicking on a button?
I have this code where i send my collection to index.ejs In index.ejs I want to sort my collection by rating from button. What way can I do it? Answer You can add in index.ejs an anchor tag that would send a request to / with a url param, something like this for example: You change you request handler, so
How can I transfer an image from html to nodejs to use it with ejs?
I was trying to create a new website using nodejs and expressjs. Basically I have a page (/ home) where there is a form with an input file. I have already created the code to show the preview of the image once loaded … what I would like to do is essentially transfer the “link” of the image to nodejs,
Getting Error while posting a request, ValidationError: TodoTask validation failed: user: Cast to ObjectId failed for value
i am getting an error while trying to post a todo to the database. ValidationError: TodoTask validation failed: user: Cast to ObjectId failed for value My function for posting the request : Schema is defined as : Answer Since the user property is defined as a ref you should just store the _id in it: When retrieving user’s information you will
“Hello World” Express does not show – I am shown my files instead
I am trying to build my first app. It’s a calculator that measures the level of caffeine in your blood. I copied the code from : https://expressjs.com/en/starter/hello-world.html (copied below), but it is not showing a page with the words “Hello World!”. Instead, I see 2 links to my 2 files within my folder “CaffeineCalc” (calculator.js + json file). I have