Skip to content
Advertisement

Tag: express

Language getting detected but translation not working with i18n

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

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

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

Advertisement