Suppose I have a nested object list like this: The object anatomy is simple: id, name, children (if any) and parentId. I’m using this flatten function that turns the nested object into a flat array: The thing is that the parentId value is not always persistent for every object, and therefore when the ob…
Tag: node.js
Nest.js cant resolve dependencies, can’t find my mistake
I’m doing a Nest.js program but I can’t find my dependencies problem. I have searched quite a lot and I have found a lot of answers regarding this problem, but I can’t figure out why my code isn´t working. So I have a product module which has his DTO´s, Entity, Controller, Service and module…
How to start item index with 1
I’m iterating through array “fruits”. I want its index to start with 1. but the output starts at 0. Here is my code here is the output. how do i make it to start with 1 ? Answer Manually add 1 to the index:
Node.js – Cannot append global variable when using fs
Im trying to read multiple xml files and parse data from them and i managed to do that but now new problem appeared. allData variable is never changed, no matter what i do. What am i supposed to do here? I dont know what to do or what to try, this is my first time working with files and im
RSA-SHA1 signature differs in JavaScript and PHP
I need to create a RSA-SHA1 signature in nodeJS, I am using the following code I’m double checked that my code result is true, I have same result with online tools if I select sha1WithRSA algorithm and I also get same result in PHP when I use openssl_sign function I need to sign data for a bank API, Unf…
Create big json object js
I am using Nodejs to Create a JSON file from a really large JSON object (1GB). In order to avoid memory problems, I’m using createWriteStream : After using Builder(custom function ) it will return a big object JSON. the final step is to create this file : but unfortunately, JSON.stringify cannot be used…
Push object to array in mongodb nodejs [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question This is my mongodb collection. I want to push object to array with findOneAndUpdate(). This …
readline not pausing for or allowing input
Here is my code: (The console.log()s are just so I can see what code is evaluated and which isn’t) This just returns What do you want me to do?2 over and over again. It also doesn’t let me type anything in to the console. How can I fix this? I’ve looked all over and haven’t found anyth…
How to split each element of a string array into different categories?
I am using node.js to fetch data from a website. Once I have that fetched data I want to insert into a mySQL database. Fetching the the url gives me a json dump of information. After formatting the string, I am using an array to store my data. Below is an example of my output: I want to split each
Why can’t I return a string literal type in TS
I don’t understand the following error: The method broken is giving me Type ‘”Ms”‘ is not assignable to type ‘T’. ‘”Ms”‘ is assignable to the constraint of type ‘T’, but ‘T’ could be instantiated with a different subtype…