Friday, 28 April 2017

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.



via learningiOS

No comments:

Post a Comment