Guest User

Untitled

a guest
Jun 21st, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. app.get('/', (req, res) => {
  2. res.send("Welcome!")
  3. })
  4.  
  5.  
  6. app.get('*', (req, res) => {
  7. jsonfile.readFile(file, (err, obj) => {
  8. let pokedex = obj.pokemon
  9. let result = []
  10. let format = req.path.split('/');
  11. let userPath = format[1]
  12.  
  13. for (var i = 0; i < pokedex.length; i++) {
  14. if (userPath == pokedex[i].name.toLowerCase()) {
  15. result.push(
  16. "<h1>" + pokedex[i].name + "</h1><ul>Weight: " + pokedex[i].weight + "</ul>" );
  17. }
  18. }
  19. res.send(result.join())
  20. })
  21. })
Add Comment
Please, Sign In to add comment