Questions tagged [express-router]

ExpressRoute is a service that enables you to create private connections between Azure datacenters and infrastructure that's on your premises or in a colocation environment.

265 questions
1
vote
1 answer

Why I'm getting Req.Req (Nested request) with this configuration in express?

EDIT: If you have the problem with nested requests or responses. Check the order of the params, or use express.router({margeParams: true}) option. My requests are being wrapped by another object request. I have to access 'req.body' that way ->…
Danilo Cunha
  • 1,048
  • 2
  • 13
  • 22
1
vote
1 answer

Error: Route.post() requires a callback function but got a [object Object]

I am trying to implement a password reset functionality into my web app and I keep getting the error in the title. My code: main.js: const router = express.Router(); const AsyncNewPassword = require('./controller/asyncnewpassword'); const…
Munchkin
  • 857
  • 5
  • 24
  • 51
1
vote
1 answer

Not Have To Specify Middleware for each Router express

In Express, I'm using different routers for each of my routes, like this: const express = require('express'); const postRouter = require('./postRouter'); const userRouter = require('./userRouter'); const app = express(); app.use('/posts',…
Tejas_hooray
  • 606
  • 1
  • 6
  • 16
1
vote
2 answers

In Nodejs Express App Route is not working

I have an app.js file as - const express = require('express'); const app = express(); const port = process.env.PORT || 8080; const userRoute = require('./routes/user.route'); app.use('/user', userRoute); app.listen(port, () => { …
Abhishek
  • 77
  • 1
  • 7
1
vote
1 answer

Node.JS/Express - Get company products using URL params

I'm trying to retrieve products from a specific company in my application using RESTful API. The GET method that I'm trying to use is something like this: http://localhost:3333/company/:company_id/products So I tried this approach: const routes =…
1
vote
1 answer

Syntax error: Illegal Break Statement on using next in middleware to pass to other middleware

I am trying to use a middleware to verify my user token. The problems come when I am trying to use next() to move on to the next middle were. What I think is that somehow my next() is not working as it should. Please help. Middleware code: async…
1
vote
2 answers

How can I route all calls starting with string api to their handlers in an express middleware

I have a express app.js with typical app.get('/path1', (req, res => {}) app.get('/path2', (req, res => {}) app.get('/path3', (req, res => {}) now I want to catch all routes, starting with api such as below and redirect them to their…
nightograph
  • 2,179
  • 5
  • 31
  • 49
1
vote
1 answer

Why Postman gives me "Not Found 404" error?

When I send a GET request to the https://localhost:3443/images/ endpoint I get this result: [ { "_id": "5e8ef5fa98c70f30a8986070", "createdAt": "2020-04-09T10:16:26.796Z", "updatedAt": "2020-04-09T10:16:26.796Z", …
Hasani
  • 3,543
  • 14
  • 65
  • 125
1
vote
1 answer

Fix character encoding in csv http response file in JavaScript

I have an API which gives me a CSV file as a response, however a lot of the content is in French and it has special characters are being screwed up. Stuff like this is appearing on the CSV files: Example√© of Wei√©√©rdness√©√© Is there a way to…
theJuls
  • 6,788
  • 14
  • 73
  • 160
1
vote
1 answer

Having issues pulling data from my database and populating it (ById) onto the my Vue view (using Axios). Backend is Node/Express

I know by the console that the route is pointing it to the correct Id number, but it's throwing a 404 and I'm not sure where the connection is going bad. PrizesById is essentially a duplicate of another route holding data called Prizes. I wasn't…
user12913705
1
vote
0 answers

How to define a route with route params separated with a colon in Express?

The route I'm trying to make looks something similar to this: /config/param1:param2:param3/ Considering param1|2|3 are all route params the route definition should look like /config/:param1::param2::param3/ which works good until the request is…
lolbas
  • 794
  • 1
  • 9
  • 34
1
vote
0 answers

Split router logic into separate functions

I have a get request handler of a Router in Node.js and it has a lot of code: const express = require("express"); const router = express.Router(); router.get("/api/employees/employee-response", async (req, res) => { try { // First action…
JAN
  • 21,236
  • 66
  • 181
  • 318
1
vote
1 answer

Express router calls the wrong route

So, I have an API with with a few routes defined (I'm not going to list all of them) where one of them never gets called unless I change it's name. this is how I define them in code: // Each middleware/function is separated by commas…
1
vote
1 answer

Combining many routes using one switch statement

I am creating an app for production use and would like to combine several routes using one switch statement. I currently use it in development and it works perfectly, however I have not seen this approach used before, and would like to know if there…
Dave
  • 147
  • 1
  • 8
1
vote
2 answers

how to fix session variable not defined in route (auth.js) while it is working fine in app.js

I am setting up a new server in the nodeJs. where Do I need to set session such that I can access session in route files?
Gaurav Gupta
  • 11
  • 1
  • 2