Advertisement
Guest User

Untitled

a guest
Jan 19th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var express = require('express');
  2. var router = express.Router();
  3.  
  4. router.get('/', function(req, res, next) {
  5.  
  6.   res.render('index', { title: 'Express' }
  7.   );
  8.  
  9. });
  10.  
  11.  
  12.  
  13. router.get('/:id', function(req, res, next){
  14.  
  15.     const db = require("../db");
  16.     var formata_id = req.params.id;
  17.          
  18.     db.findPosts(formata_id.toLowerCase(),function(err,docs){
  19.  
  20.     global.docs_info = docs;
  21.  
  22.     });
  23.  
  24.  
  25.     db.findInfo(formata_id.toLowerCase(),function(err,informacao){
  26.  
  27.     global.info = informacao;
  28.  
  29.         if(!global.info || global.info == 0){
  30.           res.render("erro2");
  31.         }
  32.  
  33.     });
  34.  
  35.     res.render('show', { title: 'Express', inform: global.info, post: global.docs_info, parametro_id: req.params.id});
  36.  
  37. });
  38.  
  39. module.exports = router;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement