https://expressjs.com/en/4x/api.html states As req.body’s shape is based on user-controlled input, all properties and values in this object are untrusted and should be validated before trusting. For example, req.body.foo.toString() may fail in multiple ways, for example foo may not be there or may not be a st…
Tag: express
How to get bcyrpt compare in a promise to work right?
I’ve had this working before, but now it’s broken for some reason. I’m using MariaDB as a database, and need to compare passwords, but it’s giving me an error Unexpected Identifier on “bcrypt” after await. When I remove the await, it works, but even if the password is wrong…
mongoose.connect() is undefined
I’m trying to connect to my MongoDB using Mongoose and it gives me the following error. I get this Error Answer You should change 2 things: Change { mongoose } with mongoose Remove useNewUrlParser option. New version of Mongoose does not accept it as option and it will throw an error.
Node/Express: Database being printed on screen rather than index.html
So, I’m using Node, but all that’s printed on the screen is my database in JSON format and not index.html. This doesn’t occur when I use localhost, so I have no idea why it does show my index page. Can anyone help me? My code: Answer I didn’t exactly understand your question properly b…
Keep getting a DELETE 400 (Bad Request) with my REST API
So, I’ve created a API and I’ve got my POST and GET requests working, but I’m can’t get the DELETE request to work. I keep getting a ‘DELETE http://localhost:3000/api 400 (Bad Request)’ error in the console. Here is the delete section in my server file: Here is the button t…
Cloudinary configuration is not read data from .env file
I’m using Cloudinary with my node.js project… The issue is cloudinary.config is not reading data from .env file, I have to type them directly! I’ll be thankful if anyone can help 🙏🏻 Answer Issue is solved with adding require(“dotenv”).config(); to the beginning of the same file w…
How to add a button to run code inside LeafletJS marker?
I am trying to add a button inside a pointer which print a log to the console. This is just meant to be a test, so I can actually make the marker run a method, but I can’t even get it to print text. When I load the page, I immediately get this error: Uncaught (in promise) TypeError: Cannot read
Leaflet : How to create marker labels based on JSON fetched from API
Users are shown points to press. When clicking a point, a menu pops up with text. I’ve been able to set down points, but when I try to retrieve data from my database when clicking a point, it shows does not show the marker specific information. Where did I go wrong? I need the pointers to only show thei…
Error: ENOENT: no such file or directory, open When trying to access a directory with fs
I am not knowledgeable in nodejs or express, I have an API running on http://localhost:3000 and one of the endpoints call a function that uses file system to read file synchronously. When I make a post request on postman, it says in the console that it can’t read a path that doesn’t exist (which d…
Refused to apply style from ‘http://localhost:2000/cssFile/style.css’ because its MIME type (‘text/html’)
I am currently trying to add my style.css file to home.ejs file render by express.js But I keep receiving the following error My file structure is like This is my express code My home.ejs: I have been trying for another solution, but I just can’t solve mine. Answer My file structure is like This is my e…