[Resolved] Nested router not working


#1

I had a /USER router. Then I created /BATTLES router and in this router have written get /LOGS method,
so finnaly it’s request string is /user/battles/logs
But it doesn’t work.
Please, help me understand what I did wrong.

Add user router:

const user_router = require("./server/routers/user");
app.use("/user", user_router);**

Add battles router inside user router:

const battles_router = require("./user/battles");
router.use("/battles", battles_router);

Battles get logs:

router.get("/logs", loginCheck, (req, res) => {
console.log(“LOGS!!!”);
userModel.findById(req.session.passport.user, “battleLogs”, (err, user) => {
if(!err) {
res.status(200).json({
battleLogs: user.battleLogs
});
}
else {
res.sendStatus(409);
}
});
});

Get method on the client:

async loadBattleLogs() {
try {
const response = await fetch("/user/battles/logs", { method: “get”, credentials: “include”, headers: { “Content-Type”: “application/json”, “Accept”:“application/json” } });
const result = await response.json();

  this.setState({
    battleLogs: result.battleLogs,
  });
} 
catch(loadingError) {
  this.setState({
    loadingError
  });
}

}


#2

Solved. I forgot add () to function…