How to get data from my function Data() instead of JSON PLACE HOLDER mock API using HTTPS/HTTP node module and how to make an endpoint of this get data HTTP/HTTPS module to utilize response in front end just like Angular? My mock backen.js file: Your time and help will be really appreciated. Thanks 🙂 Answer H…
Tag: node.js
Cannot read properties of undefined (reading ‘fitness’)
We are currently making a website for our roommate matching project. We are at the point where we are making the results page, which should display the 3 most compatible roommates based on some questions where the algorithm calculates their compatibility percentage. We are now trying to pass the object called…
How to spread object inside object
I Have an object inside another object and I want to spread the inner one, my reason is when I want to call the object by it’s id My object As shown above I want to append ‘count’ attribut inside ‘_id’ attribute , i couldn’t spread the inner one so How can I do it Answer Yo…
Nodejs wait till async function completes and print the results
I want to wait on the HTTP POST request to complete and then return response to the caller function. I am getting Undefined when I print the received results. I have defined post method as below: And I am calling it in this way: I don’t want to handle the .then and .catch in the calling function as I wa…
Object property UNDEFINED in VUE v-for
I have this object inside an array called places which contains 20 similar objects and im using v-for to get each objects data into a div, other properties work fine, but when it comes to the openingHours.text property, it gives an error of undefined you can check the images below for more clarity figure 1 fi…
How to generate unique random emails with nodemailer
I would like to use nodemailer in a few tests to be able to pragmatically test the contents of an email that is sent. So far, its working great but there is one issue I haven’t been able to solve. I am using the createTestAccount from the Javascript nodemailer, and notice that it often returns me the sa…
Connect mangoDB Atlas with nodejs
I can’t connect to MongoDB database, yet I tried everything ! I have successfully replaced the password. Here is the Database MangoDB Answer You will need another function to complete the operation. the function is usually called run then you need to write all the operations of your server in the scope …
Two routes use params but only one is working
I’m trying to make a website that show you all the restaurants in the country with all th different cities. I add a route for restaurants that use params to redirect you to the restaurant page. And another route that also use params to take you to the city details page The problem is that only the resta…
Get the nearest object key from object containing multiple objects with numeric keys
I have an object containing an undefined number of child objects which are associated by numeric values as the object keys. What I need is a way to pass in a numeric number (currency) and get the child object that is the closest to the number I pass into the function. Example Object structure The keys of the …
How to do an If await by the async function response
I’m trying to create a function that checks if a table already exists in the database and if it doesn’t, create one But the problem is the If doesn’t await for checkTableExist() Console Log Answer In checkTableExist you are checking your DB Query results using a callback function. In there, …