I have set up the i18n middleware in my Express Node js server like this: Here is the translation test file: The value of title in English is title and for Malaysian, it’s tajuk As per the express middleware documentation, I’m passing my as the accept-language header , and console.log(req.i18n.language) is correctly printing it. However, console.log(t(‘title’)) is still printing title
Tag: express
“Error: MongooseError: Operation `users.insertOne()` buffering timed out after 10000ms”,
I’m running MongoDB Atlas on node express and I got this error when I tested with postman. This is my .env, I’m guessing the problem might be here too, Kindly help: Answer In my case, I had to go to Atlas, and reset my whitelisted IP to the correct address. Then I restarted my local server and tried posting again
Express Sharp install via Docker issue
I need to use sharp. Its work fine on my workspace but if I deploymeny via docker then I get error. I am implementation all steps. I think sharp is prebuilt when first install. It uses the architecture of my computer(darwin, arm) But when it runs on the docker, although it gets built again, the work talks about the architecture
API return values based on certain criteria
I am working on an API, and I want to return values based on some input I receive. For example, here is a body sample input Based on the fields array, I want my API to return only those values. Here is an example of the API implementation So the part where I indicate stuck here I want to loop
How to remove falsy values from array of objects
I have an array of objects like so, I want to remove the last object from the array since it has falsy values, I tried to achieve this by writing a simple function like so That didn’t fix the issue, I also tried to use but that just returned the keys in the object, how can I achieve this, please?
How to query on collection values and referenced documents values in MongoDB?
I don’t know how correctly I formulated the question. I need to execute a query on both the values of the collection and the values of the referenced objects. The original collection looks like this: When executing a query that meets the condition district == “Texas”, I need to get the following result: Under this condition: kind == “developer”, get
Cannot read property ‘path’ of undefined while uploading image upload on the frontend(react)
I am trying to upload an image on the frontend, but this is not working, I am getting the error below When I log req.file on the backend and try to upload on the frontend, I get undefined in the console, but this gets logged for req.body Image upload works fine on the backend via Postman. Here is the frontend
multer npm: TypeError: Cannot read property ‘path’ of undefined
I have a problem uploading an image file to my server, I watched a tutorial on YouTube about multer and I do exactly the same thing that is done in the tutorial and for whatever reason I get an error: (“TypeError: Cannot read property ‘path’ of undefined”). I googled for the error and found some people having the same issue
Setting Socket.io room variables
I would like to store some information in the socket room variables, but am getting the following error: UnhandledPromiseRejectionWarning: TypeError: Cannot set property ‘host’ of undefined This is my code: If I try to log socket.roomId it would return something like rBAhx0. And when I log io.sockets.adapter.rooms, I get the following: However, when I try to log io.sockets.adapter.rooms[socket.roomId], it returns
How to exclude fields on return in mongoose
I have the following code: It works perfectly but say I want to exclude a field returned, like the __v field. I know I can do this by just creating an object like and etc. for teh other fields, however if I have 20 fields I don’t want to list every single one, so is there a way for mongoose