I am trying to connect From Node.js on Localhost to MySQL instance running on docker using docker-compose. Node.js gives me this error: ENOTFOUND db, Full error message bellow. Here is docker-compose.yml that contains MySQL and adminer services. Here is my node.js database connection config. Answer You don…
Tag: node.js
Electron Amplify AppSync “Realtime disabled when in a server-side environment”
I’m using amplify appsync in my electron app and all works except for the realtime events which means my app doesn’t get signalled when the data changes in the cloud. I know this is because it’s running in Node which is what amplify is looking for (JS.browserOrNode) however I don’t kno…
Return File Data With A Custom Function
I am building my own project (website) and I am trying to create a renderTemplate function to return HTML files but I don’t how to return data from the file Here is quick example of what I am doing I made sure the file.txt exists, ran the code and got undefined in the output Answer Because render doesn …
Uploading an image to an API with multer
I’m trying to make an application that requires image uploading and storing, I’m using Express, Mongoose and Multer and trying to upload to MongoDB. Currently when I try to upload an image, Multer does create a folder and store the image in that folder, but it doesn’t save the item to the da…
Number with too many decimal places ends up in scientific notation
I am getting a price from a 3rd party API which is returned in scientific notation. When I actually check this price on their site, its shown as 1.20 but the api returns 1.2052626e I want to perform a multiplication with that price field and format it to a currency string but it always returns as 0.00 cause o…
How to create a JS file with a command DISCORD.JS
I’m making a discord bot and I was wondering if you can create a .js file with it. I haven’t found a way to do it. My command reacts to &createfile {name} and it will always create a .js file. My code so far: Answer Simply use the built-in fs module. It is built into node, so it doesn’t …
Typescript SyntaxError: Cannot use import statement outside a module (side file containing functions)
I am creating a minecraft bot using mineflayer library. After a bit of work I decided to make code readable and reusable (image of file organisation) and also start using typescript. I have read a lot of stack threads and other articles as this problem is quite popular. However, after trying all of it the pro…
Update Javascript code to Typescript to fix implicitly error
I’m working on my first react (Typescript) project and there is an issue with my code below. I’m getting this error – Parameter ‘name’ implicitly has an ‘any’ type.ts(7006) Bellow is my full code How can I fix this so that works without me needing to set “noImpl…
Nested async await function not executing in AWS Lambda Function
Problem: I have very little experience working with async await functions and I am trying to execute a nested async await function within an if-else statement that depends on a higher level async function to execute upon an event detection. I expect to get a successful http response back from the nested async…
save/remember an Alexa user’s intent confirmation response?
I have a confirmation prompt for one of my Alexa skill’s intents, and now I need it to “remember” the user’s answer and not ask the user again. Essencially, we want the user to be prompted only on the very first time they use the skill, and then never again. Is that possible? I’m…