Category : node.js

I am trying to fetch student details details from JWT token, as per my observations, I think my JWT is not recording any student details in it. I have gone through many videos and googled not found here is my code: const express = require("express"); const router = express.Router(); const newStudent = require("../models/studentModel"); const bcrypt ..

Read more

iam new starter at node.js , i write my code right but still got error promise is not defined after run node test.js , please i hope some experience developer have solution for this error here is the code for my 2 files include in node js project : first file is >> test.js const ..

Read more

Read routes from a file using an express router routes file looks like this: /users(path) isAuthenticated(middleware) UsersHandler(controller) POST(method) Does this even make sense? I saw it how it was done in Yesod and I wanted to do it for Nodejs const requireAndResolve = (dir, file) => { const fn = require(resolve(dir, file)); if (!fn.name.length) Object.defineProperty(fn, ..

Read more

My app is react on frontend and express on the backend. Renders fine when running in development mode on a local server with webpack via npm run dev, but when I try to run it in production mode via npm run build followed by npm start, it fails to render and I get ‘Uncaught SyntaxError: ..

Read more

In my backend server which runs on express I have: app.post("/login", async(req, res) => { try { const { username, password } = req.body; let result = await checkCredentials(username, password) console.log("result of checkCredentials:", result); res.json(result); } catch (error) { console.error(error); } }); on post, the function checkCredentials get’s called const checkCredentials = async (clientUsername, clientPassword) ..

Read more

I’m created a simple api, for this I’m using node.js + express. Also I’m using body-parser. But when I try to get req.body I get undefined. Here is my app.js: const express = require(‘express’); const bodyParser = require(‘body-parser’); const app = express(); const router = express.Router(); const port = process.env.PORT || 8080; app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: ..

Read more