How can I, in this code, take the data that has been changed in MYSQL and return it in another function? For example, take the id_ticket column and use it in another function. Answer onEvent is a handler, you just need to pass a function to that handler and
Tag: node.js
socket.io Get data io.sockets.clients(); Not working anymore
Before you can create objects with user properties on frontend and assign it to the socket.user property for each connection using a code like this ex below in the backend. then retrieve all these data through the sockets object eg. But now the io.sockets.clients is not working anymore and is not recognized a…
How to check if a function is running in worker thread in node?
I am trying to use worker_threads in node to run some expensive calculation without blocking the main thread. Is it possible to check if the function is actually running in worker thread, just like using the performance tab in browser devtool? Answer If the worker thread is running blocking code which is pres…
Different types of the field _id of rows after importing data to mongodb and after the creation
I’m trying to write a JS app with MongoDB (I use MongoDB Compass). I have a schema of user: Then I import some data from JSON file like this: After the importing the type of field _id is String. But, if I create a user by method create: the type of _id is ObjectId, therefore, I can’t use methods l…
Can’t Push data One to Many Relation (nodejs ,mongodb)
I am trying to insert data into MongoDB database but I get this error Cannot read property ‘push’ of undefined. I can’t understand what is the issue is here in my code. please help me with the solution. I am a Student and learning it. here I am trying to push service into the category Model.…
UnhandledPromiseRejectionWarning: DiscordAPIError: Unknown Role in my code
I have a few lines of code that are causing issues, This produces the following error: I have no idea what the issue is and im really confused, any and all help is appreciated. Answer Dude you need to use === instead = in line 1!
Why do i get minus function error in cloud function node js?
I use bignumber in nodejs for cloud functions with firebase.I added BigNumber at the end thinking that it might help. I get this error in Cloud Function Log TypeError: Price.minus is not a function Answer Your typeof Price might be a string. So it needs to be converted to BigNumber. You can use TotalPrice wit…
not able to consume thezipcodes.com search api data
I am new in nodejs and I want to use www.thezipcodes.com /api/v1/search api to search the zip code to locatioin. I am not able to use the location returned by the API. Output is In curl it is giving the output but in nodeapi I am not able to use the location array. Answer You should follow the example given
NODEJS: Return array of arrays from dialog openDirectory
I am working in a electron desktop app, and what I need to do is: Open a directory using ‘dialog.showOpenDialog’. Filter the files by their extension. Read filtered files (they have no header). Parse them into columns and return only columns 4 and 6 (coordinates). Return an array of arrays of all …
Upload into specific folder Firebase Storage NodeJS?
Hey I have found out how to upload into the firebase storage: As you can see with my bucket.upload function I can upload to firebase storage but it gets uploaded into the root folder and I want to put it under /foodImages/myfile.png for example Any ideas ? Answer Actually Google Cloud Storage does not have ge…