Skip to main content

All Questions

0 votes
2 answers
52 views

Unable to Log Outside of app.js in an Express Application

I'm working on an Express application using Node.js, and I'm facing an issue with generating logs outside the app.js file. Here is my setup: In my app.js file, I'm able to generate logs as expected. ...
Italy Zia's user avatar
-1 votes
1 answer
245 views

Node.js API multiple get request routes (Frontend - Backend)

I´m working on a project with Node.js API, that have a frontend and a backend. Ich habe already a API-folder inside the frontend, that await for the get request from the backend and that works for the ...
maladez's user avatar
1 vote
1 answer
135 views

Path exists in expressjs but says POST 404 (Not Found)

So I am stuck on a very basic route error. Project Structure: - controllers authentication.js - routes auth.js pages.js - views register.html - server.js Respective codes controllers/...
first's user avatar
  • 743
2 votes
1 answer
1k views

Accessing Global Variables within Routes in Express

I'm still new to Express, so please bear with me. What I'm trying to do is store some of my environmental variables in a global variable such that they can be accessed in any route without having to ...
dentalhero's user avatar
0 votes
1 answer
224 views

Implement function in async

I want to implement a function in async. This code is for authentication, that if user is logged in, than can't reach the page without login. My code in app.js file worked, there is the isLoggedOut ...
kiszod's user avatar
  • 127
0 votes
1 answer
117 views

Calling auxiliar function from main function working in different routes [Node/express]

I have the following structure in the project: root ├── models ├── routes └── controllers In the routes I specify the route-method pair. Something like this: router.get('/',verifyToken,controller....
user avatar
0 votes
1 answer
315 views

Is there something changed on express, router, consign or I just don't know what I'm doing so wrong?

I have installed my dependencies, I've set up my app, but now I'm trying to set a route using consign and I can't find my folder through the middleware using consign. 1 const app = require('express')()...
user avatar
-1 votes
1 answer
173 views

nodemon keeps crashing because of route.get() file errors

I'm stuck on the last bit of the fourth MDN tutorial where you're to run nodemon to check out your routes/controllers to see what you've done running them on a localhost. It says I have an error with ...
Bridgette's user avatar
1 vote
1 answer
95 views

How can i use/change 2 "res.render" in different files?

I don't know if the "res.render" can used twice. The error is: C:\ReactVap\vapinto\src\controller\LaunchController.js:45 return res.render('index', { launch }) ^ ...
Vinicius Pinto's user avatar
1 vote
1 answer
2k views

Is it a bad idea calling a controller from another controller?

I am building a web service with node.js and express.js and trying to use a MVC architecture for the first time. I have an html form that the user sends to a specific route (suppose POST to /...
Llus's user avatar
  • 55
0 votes
1 answer
24 views

Trying to move express API code to controller file

I am missing something obvious here. in my routes/api file this works fine (I get the expected users back from mongodb) const User = require("../../database/models/User"); router.get("/...
AdamCodes716's user avatar
1 vote
1 answer
375 views

Database query in Express error: Router.use() requires a middleware function but got a undefined

I'm setting up a controller, model, route, and view in my express application. Modifying my application that was working with just a view, I am getting this error: Router.use() requires a middleware ...
baumli's user avatar
  • 471
3 votes
1 answer
5k views

How to use express-async-handler

I am going through some code on github: https://github.com/linnovate/mean/blob/master/server/routes/user.route.js But there is a portion of it I don't understand, that is: router.route('/') ....
YulePale's user avatar
  • 7,796
1 vote
2 answers
537 views

Express + Mongoose: async/await returning undefined

I'm trying to separate route code from database codes, but I'm stuck with an error when the route make an call to controller method. I have the productRoutes.js: router.route('/') .get(async (...
pcs980's user avatar
  • 33
3 votes
2 answers
14k views

API GET request from my api to another api?

I'm trying to create a backend that sends a GET request to another API. For example: My API: localhost:3000/ Route: /getdata/data1 Other API: api.com/target/data (This is a fake URL, just assume ...
Ext-'s user avatar
  • 541

15 30 50 per page