Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"res" is not defined #7

Closed
abhi18av opened this issue Jul 20, 2016 · 2 comments
Closed

"res" is not defined #7

abhi18av opened this issue Jul 20, 2016 · 2 comments
Labels

Comments

@abhi18av
Copy link

abhi18av commented Jul 20, 2016

Hey, I'm trying to use the wonderful wrapper in NodeJS but for some reason I'm unable to get this thing running. I'm a passionate noob starting out with the Web so could you please help me out a bit.

Here are the specs

'''bash
There was an ERROR: [ReferenceError: res is not defined]
'''


npm - 2.15.5
nodejs - v4.4.5

Directory setup

├── node_modules
│   ├── pokedex-promise-v2
│   └── promise
├── package.json
└── pokefile1.js

@Naramsim
Copy link
Member

Hi, thanks for using this wrapper.
You are getting that error because res is not defined. Usually, this wrapper is used along express.js which lets you do the following:

var express = require('express');
var app = express();

app.get('/', function (req, res) { // res here is a parameter
  res.send('Hello World!'); //you use it for serving content to clients
});

So in the examples we use res to show how to serve the content retrieved from the PokeAPI while using express.

To test if your installation works fine just use this code:

var Pokedex = require('pokedex-promise-v2');
var P = new Pokedex();
P.getBerryByName('chesto')
    .then(function(response) {
      console.log(response);
    })

It will log you the response Object. No need to use res and express

@abhi18av
Copy link
Author

abhi18av commented Jul 20, 2016

Ah, yes now it works perfectly! I appreciate the explanation.
Grazie Allesandro! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants