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
2
votes
3 answers

Express.js - req.query vs req.params

Before you mark this as a duplicate, please understand that I was not able to get the explanations I was looking for from other answers. If I was making an app that looked for a customer based on a URL id, what is the difference between saying…
Isaac Krementsov
  • 646
  • 2
  • 12
  • 28
1
vote
1 answer

How to add meta-data to an express route and then read them using router.stack?

I have a set of routes that are defined in a routes.js file like so: const express = require('express'); const router = express.Router(); const controller = require('../controllers/mycontroller'); router.get('/',…
darksky
  • 1,955
  • 16
  • 28
1
vote
0 answers

Express router module losing params

I'm refactoring my router in express app, and I'm facing an issue regarding the params of the query. I splited my routes into multiple files, and created router modules for each. These routes are registered in an index.ts : import focRoutes from…
Yabada
  • 1,728
  • 1
  • 15
  • 36
1
vote
1 answer

Express routes invoking multiple router function

I've created a NodeJS Express app. But my express route is invocking multiple routes function, one after another, but I only need one at a time. My express app.js app.use(routes) Express router: const router =…
1
vote
0 answers

Express Endpoint to Run Axios Get Request

The problem that I am running into is that I am trying to create an express route that I can run a seed script or cron job against which when hit will then run a GET request, with Axios against an external API endpoint on a scheduled basis, get the…
Mike Tower
  • 17
  • 2
1
vote
2 answers

Path as parameter in route path

I need to follow a spec that requires a GET using a "path" in route path. Scenario #1: https://example.com/param1/param2/file.txt Scenario #2: https://example.com/param1/param2/folder/file.txt Initially I tried with the very standard…
dfelix
  • 23
  • 1
  • 8
1
vote
1 answer

Node.js Route to Controller not applying Controller constructor

I have an express.js application that uses the express.Router() to connect my endpoints to controllers. My goal is to have an object newed up in the controller constructor so I can use it in all controller functions without having to new it up in…
A. Hasemeyer
  • 1,452
  • 1
  • 18
  • 47
1
vote
1 answer

How to route all routes through router.js file with Express?

I have app.js file where I route /api routes to api.js file: const api = require("./src/rest/api") ...... app.use("/api", api) I am planning to to do all routing in router.js file, so router.js file would look like this: app.all("/api",…
ferakp
  • 83
  • 2
  • 9
1
vote
1 answer

Express empty req.params route to the previous route

Suppose that I have the following REST endpoints /api/companies /api/companies/:id /api/companies/name/:slug The first route /api/companies POST will post a new company, while GET will fetch list of all companies. The second route…
miserylord
  • 300
  • 2
  • 15
1
vote
1 answer

Conditional Routing in Express

I have 4 controllers for 4 different situations. I am trying to call the 4 controllers from the same endpoint depending on the different request queries. I have implemented the logic as below: const express = require('express'); const quesController…
Rounak
  • 85
  • 2
  • 7
1
vote
2 answers

Can I dynamically generate routes path based on a database table property in express?

I was trying to fetch data from permission table and give a route path depending on the data. Let assume I have a permission table where in slug property I saved a path url. Then I want to find those url and write them in my routes path. I am trying…
Tanmoy Sen
  • 111
  • 10
1
vote
1 answer

How to solve: Error: Route.get() requires a callback function but got a [object Object]?

Routes Folder Structure Note: There was no problem, until I added docs_router.js docs_router.js const { control_docs_v1, ipManager } = require('../controllers/indexer') const router = require('express').Router() router.get('/v1', ipManager,…
Curious Learner
  • 1,182
  • 1
  • 4
  • 17
1
vote
2 answers

TypeError: Cannot convert undefined or null to object - when trying to execute MySQL query in router

I have a route where I execute a few MySQL queries - the final query is a SELECT using the 'email' value from a previous query executed in the route as criteria. I have tested a few of these 'email' values using MySQL Workbench and I get results, so…
Todd Brannon
  • 182
  • 3
  • 16
1
vote
0 answers

MongoDB query to get top selling products

I have a MongoDB collection "orders" with document similar to such: { "_id": ObjectId("xxxxx"), "orderNo": 0, "products": [ { "product1": ["_Id": objectId("eeee"),"productName", "quantity", "price"] }, { "product2":…
1
vote
1 answer

Why i am not getting proper response after giving request for specific parameter ? (REST API USING NODEJS AND EXPRESS ROUTER)

Created a Node module using Express router to support the routes for the dishes REST API. Index.js file: const express = require('express'); const http = require('http'); const morgan = require('morgan'); const bodyParser =…
divyanshu_31
  • 65
  • 1
  • 6
1 2
3
17 18