Skip to content

Instantly share code, notes, and snippets.

View aktasfatih's full-sized avatar
🏠
Working from home

Fatih Aktas aktasfatih

🏠
Working from home
View GitHub Profile
@aktasfatih
aktasfatih / nodejsExample.js
Last active July 10, 2019 22:02
Route example
router.post('/userInfo', function(req, res){ // Route for handling the request
jwt.verify(req.body.token, JWT_SECRET, (err, decoded) => { // Checking if the JWT token of the user is valid
if (err){ // Handling error
res.json({
"info" : "Error0"
});
}else{
if(typeof decoded.username === "undefined"){ // Checking if username is defined in the request
res.json({ // Handling the error
"info" : "Error1"