Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

209
Views
Node express issue, get the following "Cannot GET /test" in browser

I have the following node express function:

var express = require('express');
var app = express();

// Listen on port 8000, IP defaults to 127.0.0.1
var server = app.listen(8000, function() {
    console.log("node express app started at http://localhost:8000");
});

app.get("/test", 
  function(error, request, response, next) {

    request.set("Content-Type", "text/html; charset=UTF-8");

    if (error) {
        request.status(403);
        return next();
    } 
        var id = request.query.snuid;
        var currency = request.query.currency;
        var mac_address = request.query.mac_address;
        var display_multiplier = request.query.display_multiplier;
        //
        request.status(200);
});

When I load up the browser and enter in the url:

http://localhost:8000/test?snuid=1234&currency=1000&mac_address=00-16-41-34-2C-A6&display_multiplier=1.0

Im not sure why I am getting this error!? Not sure, it should work based on the documentation and examples I have seen. Any help would be appreciated.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I think is because you want to use a middleware and not a route, so maybe your code can be write in this way:

var express = require('express');
var app = express();


app.use(function(err, request, response, next) {
    if (error) {
        request.status(403);
        return next();
    } 
});

app.get("/test", function(request, response, next) {

response.set("Content-Type", "text/html; charset=UTF-8");

var id = request.query.snuid;
var currency = request.query.currency;
var mac_address = request.query.mac_address;
var display_multiplier = request.query.display_multiplier;
    //
    response.status(200).end();
});

// Listen on port 8000, IP defaults to 127.0.0.1
var server = app.listen(8000, function() {
  console.log("node express app started at http://localhost:8000");
});`
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!