Quantcast
Channel: Active questions tagged express - Stack Overflow
Browsing all 9172 articles
Browse latest View live

How to unit test express Router routes

I'm new to Node and Express and I'm trying to unit test my routes/controllers. I've separated my routes from my controllers. How do I go about testing my routes?config/express.js var app = express();...

View Article


Access current req object everywhere in Node.js Express

I wonder how to access req object if there's no 'req' parameter in callback.This is the scenario:In ExpressJs, I have a common function, it uses to handle something with 'req' object, but not pass req...

View Article


How do I display flash message without page refresh using express and...

Express connect-flash displays only after refresh. Code is stripped for easy reading."express": "~4.2.0","connect-flash": "~0.1.1",And here is my app.jsvar express = require('express'), favicon =...

View Article

401 (Unauthorized) from react and node

I am building a website that accept crypto payment through coinbase using react, node and firebase.Ever since I added a verify token middleware to my node backend I keep getting a 401 (Unauthorized)...

View Article

JavaScript Server Build Bundle

It seems that with the modern JavaScript approach resumability, lazy load, on demand etc. All of those things lead to a lot of chunk files, when we build the application.Once we build the application...

View Article


Image may be NSFW.
Clik here to view.

Cannot set headers after they are sent to the client. NOT USING TWO RESPONSES

JUST WANTED TO ASKafter hitting the entry-point I had this error messageError [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client at new NodeError (node:internal/errors:372:5)...

View Article

Change blob (consisting image) into image and put this image into

So. I am adding record to a database (MySQL with XAMPP and "mysql2": "^3.6.2" package) byexport const addPage = async (req,res) => { try { if(req.session.user !== undefined) { const body = req.body;...

View Article

How to load data to radio buton and modify them with React

I am new to react and I have a problem with Express (database: MSSQL) and React.I have this fictive database, and I would like to visualize the data per person with radio buttons like this.When I tried...

View Article


How to get ChatGPT API working with backend to frontend when getting CORS Error?

I'm trying to get a final project working with the ChatGPT API working. Just running my the ChatGPT API in Node.js works great, but I need to interact with the front end to get user input where I ask...

View Article


i am getting the error "Passowrd is wrong" when tried to login , i used pre...

before implementing the pre save hook in mongoose the login api is working perfectly but after implementing the pre save hook i consistently getting the password is wrong error i tire to log the...

View Article

Unable to Trigger Mongoose Pre/Post Hook on Document Deletion

I am facing difficulties in implementing pre and post hooks for document deletion in Mongoose. I have tried various approaches, including using deleteOne, deleteMany, findOneAndDelete, and...

View Article

Image may be NSFW.
Clik here to view.

Trying to insert HTML from my database MySQL [duplicate]

Im trying to insert HTML from my database MySQL with nodejs.I get the products from my databaseexport async function getAllProducts() { try { const response = await...

View Article

Image may be NSFW.
Clik here to view.

Express.js large file download freezes / hangs

I'm having some trouble with downloading large CSV files from a Node.js Express server, which freezes / hangs at times in the browser. I'm using the res.sendFile() function on the server (using...

View Article


Image may be NSFW.
Clik here to view.

How do I allow an AWS ECS Task to upload a file to an S3 bucket in the same...

I have an S3 bucket called development-test with zero permissions configured for it. I also have an ECS task setup in Fargate. This task has a task role called PDFGeneratorTaskS3BucketPutPolicy with...

View Article

Handling Errors in Nodejs Application when Redis fails

I have written a module named Cache in my express application,Which uses Redis for caching,I instantiaited Redis during app initialisation,I want to handle errors across the application,incase of Redis...

View Article


API Documentation for typescript types for JS libraries

I am trying to develop an exrpessjs application in typescript. I installed @types and developed a working application after reading some articles. My question is where do I find documentation for...

View Article

Image may be NSFW.
Clik here to view.

Error: secretOrPrivateKey must have a value

I am using jwt to create token, but when i login via postman I get the error "Error: secretOrPrivateKey must have a value" from my console. I have attached my login code. Please anyone who can help...

View Article


Getting an error: {"message":"Invalid content type. Please send data as...

In my server.js i have this:// app.use(express.json({ type: 'application/json' }));app.use(express.json()); // Handles both JSON and urlencoded dataapp.use(express.urlencoded({ extended: true })); //...

View Article

Error when serving static react website with express.js and a route path

I'm trying to build a website with express and the vite react template, both using typescript.If I serve my static files withserver.use('/', express.static('../mySite/dist'));I can access the page with...

View Article

"findById is not a function"

I have written this code and tried to delete the posts of a user while deleting the user's account. Now, findById is working fine foe the user but when I'm trying to delete the posts inside a loop it's...

View Article
Browsing all 9172 articles
Browse latest View live


Latest Images