pipedrive / client-nodejs

Pipedrive API client for NodeJS
MIT License
209 stars 81 forks source link

Confusing usage in README? #579

Closed timneedham closed 3 weeks ago

timneedham commented 4 weeks ago

Hi,

The README states:

Warning

The pipedrive.ApiClient.instance has been deprecated.

Please, initialise a new pipedrive.ApiClient() instance separately for each request instead.

Yet the example straight after it, doesn't initialise a new AppClient instance separately for each request?

If it were each request, I'd expect something like:

app.get('/', async (req, res) => {
  //  Initialise a new pipedrive.ApiClient() instance separately for each request 
  const defaultClient = new pipedrive.ApiClient();  
  let apiToken = defaultClient.authentications.api_key;
  apiToken.apiKey = 'YOUR_API_TOKEN_HERE';

  const api = new pipedrive.DealsApi(defaultClient);
  const deals = await api.getDeals();
  res.send(deals);
});
youssef-saber-3 commented 4 weeks ago

Hey @timneedham , Yeah, you're right. that's an oversight on our part, we'll update the readme to reflect the recommended way of doing it. thanks for pointing it out!

youssef-saber-3 commented 3 weeks ago

fixed in https://github.com/pipedrive/client-nodejs/pull/580