Thursday 26 March 2020

Most end-points returning a 404

I'm making my call both from localhost:2018/ and from an api located at localhost:8080/new. Only request working is POST on /authconst express = require("express"); const app = express(); const port = 2018; //Port used // Mock data imports //One data import from post is missing here const renewalResponseJSON = require("./data/renewalResponse"); app.use(express.json()); app.use(express.urlencoded({ extended: true })); app.use(function(req, res, next) { res.header("Access-Control-Allow-Origin", "*"); // update to match the domain you will make the request from res.header( "Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept" ); next(); }); app.get("/entity/:uid/canRenew", (req, res) => { const uid = req.params.uid; if (uid != null) { res.status(200).send(renewalResponseJSON); } else { res.status(500).send(); } }); app.post("/auth", (req, res) => { res.status(200).send(principalJSON); }); app.get("/entity/plate/:plate", (req, res) => { const plate = req.params.plate; if (plate != null) { res.status(200).send(fileJSON); return; } else { res.status(500).send(); return; } }); // Run server app.listen(port, () => console.log(`Mock-server listening on port ${port}!`));

Submitted March 26, 2020 at 06:52PM by mslayaaa

No comments:

Post a Comment