Gabb-c / pokenode-ts

A lightweight Node.js wrapper for the PokéAPI with built-in types.
https://pokenode-ts.vercel.app/
MIT License
248 stars 29 forks source link

Usage of await + .then in documentation #1232

Open robert-westenberger opened 1 month ago

robert-westenberger commented 1 month ago

Version of Pokenode-ts

1.20.0

Node.js Version

20.16.0

Operating System

macOs

Bug Description

This isn't really a bug, more of a question. Why mix await and .then? Seems like an oversight.

Expected Behavior

Just use await, theres no reason to mix await and .then

Steps to Reproduce

Look at the documentation here https://pokenode-ts.vercel.app/guides/getting-started#basic-example

import { PokemonClient } from 'pokenode-ts';

(async () => {
  const api = new PokemonClient();

  await api
    .getPokemonByName('luxray')
    .then((data) => console.log(data.name)) // will output "Luxray"
    .catch((error) => console.error(error));
})();
import { MainClient } from 'pokenode-ts';

(async () => {
  const api = new MainClient();

  await api.pokemon
    .getPokemonByName('luxray')
    .then((data) => console.log(data.name)) // will output "Luxray"
    .catch((error) => console.error(error));
})();