freshbooks / freshbooks-nodejs-sdk

Node.js SDK for the FreshBooks API
MIT License
8 stars 12 forks source link

Listing projects throws TypeError when auth token is invalid #450

Closed isaacd8k closed 1 year ago

isaacd8k commented 2 years ago

When using the FreshBooks client to make a request in the form of client.projects.list(businessId), the function call throws a TypeError when the access token is expired, instead of returning an http 401 error in the form described in the docs

How to reproduce

  1. Create new client using a pre-generated access token that is expired or invalid
  2. List all projects using the .projects.list() function
  3. Throws runtime exception: TypeError: Cannot destructure property 'total' of 'meta' as it is undefined. The stack trace seems to point to the axios library

See this repo for a working example of this issue

Expected behavior

Calling this function should return an HTTP 401 Unauthorized response and an error as described in the docs:

{
  ok: boolean
  data?: T
  error?: Error
}
amcintosh commented 2 years ago

Thanks for the report! I've confirmed the issue. We'll take a look.

bmcfads commented 1 year ago

Fixed in version 3.2.1