by using module.exports = var; and const var = require(“./file.js”); we can access a variable from another file but the imported variable is static and cannot change even if the original variable changes in the original file, how can I export an array that can be updated at any time and accessible in real time in another file? Answer put
Tag: node.js
How to create Polls on LinkedIn
I was able to successfully create regular Text, Image and Video Shares on LinkedIn using the Shares API. Now, I also need to create Polls on LinkedIn and I’ve searched so much around but can’t seem to find any documentations on how to do that using the Shares API. Does LinkedIn support creating Polls programmatically? If yes, can anyone suggest
I keep getting an error in my terminal, “error address already in use :::5000”
I’m following a node.js crash course and I get to the part where we are creating a server, but for some reason every time I try to run node index which is my js file name I’m getting the error: address already in use :::5000 I’ve looked through similar problems and tried to kill that specific port but nothing seems
how to auto generate id like AB22020001 in nodejs
i want auto generate id like “DC” + yaer + mounth + 4 digit in nodejs. I am using node js to create an api to connect to the database which I use phpmyadmin I want to create an id like AB22020001 But now all I can do is create an ID like AB2202. I don’t know how to make
Get specific elements of a Map in javascript
For a given map like this: How can I get the list of “phone”s? Something like: expected answer: [“213-555-1234”, “617-555-4321”] Answer You can directly iterate the Map object using its built-in iterator that works with a for loop. This has the advantage that it doesn’t make unnecessary intermediate arrays or copies of the data. As such, it should be more
How do I wait for multiple promises to resolve but also include a set minumum delay?
I am calling two APIs with two different functions and having a setTimeout for both, is it possible to handle their timeouts in such a way that they finish in 10s instead of 15s. Is there a way to run this code only in 10s, so that both the APIs get called in 10s time period Answer Forcing either one
Is there a way to edit an image before saving it to the database?
Our images are being uploaded by the users on the web application (React) and being saved on the database by our API (Loopback). The images will be used in our Qt application and they should have round corners. We have some processing limitations so we can’t clip or mask the images on Qt. We have some out of proportion images
Possible to validate against elements in an array?
I am using validate to validate input, and I need to validate an input that has to be one of the numbers in my arr. If I try enum: arr, then it takes the entire array and not just one of the elements. Question Is it possible to get validate to use one of the numbers from arr? Answer
Pause a for loop until function is completed
I’ve been scratching my brain at this a majority of the day, I am attempting to download multiple files that have iterating ID’s, I use a for loop to iterate and call a web request that calls a function that downloads a file. However, I noticed files tend to get corrupted due to multiple files being requested at once, I
Function recursion advice
I am building an employee tracking app. I want my app to work so that after each one of the functions for the various list selections is complete, the app will re-prompt you with the options list again. There are a few methods I can think of to achieve this but I was hoping a more seasoned developer could recommend