File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -148,6 +148,23 @@ class Pokedex {
148148 return await this . makeRequest ( path ) ;
149149 } ;
150150
151+ /**
152+ * Returns an array of Pokémon objects containing all the forms of the Pokémon specified the name.
153+ * @method getPokemonByNumber
154+ * @param {String } name The name of the Pokémon
155+ * @returns {Promise<Object> } Resolves information about the specified Pokémon
156+ * @example
157+ * // It's best practice to use encodeURIComponent() to encode the name
158+ * // string so the API server doesn't respond with 404.
159+ * pokedex.getPokemonByName(encodeURIComponent('Pikachu'))
160+ * .then(pokemon => console.log(pokemon))
161+ * .catch(console.error);
162+ */
163+ this . getPokemonByName = async function ( name ) {
164+ let path = `/pokemon/${ name } ` ;
165+ return await this . makeRequest ( path ) ;
166+ } ;
167+
151168 /**
152169 * Returns an array of Pokémon objects containing all the forms of the Pokémon specified the Pokédex number.
153170 * @method getPokemonByNumber
You can’t perform that action at this time.
0 commit comments