7eggs/node-toggl-api

Update API URL

sbacarob opened this issue · 2 comments

Toggl has recently rebranded and is now track.toggl.com, recently, when trying to use a CLI tool that uses this package, I get an error:

TypeError: Cannot read property 'forEach' of undefined
    at Request.onresponse [as _callback] (/node_modules/toggl-api/lib/client.js:138:7)
    at Request.self.callback (/node_modules/request/request.js:185:22)
    at Request.emit (events.js:315:20)
    at Request.<anonymous> (/node_modules/request/request.js:1154:10)
    at Request.emit (events.js:315:20)
    at IncomingMessage.<anonymous> (/node_modules/request/request.js:1076:12)
    at Object.onceWrapper (events.js:421:28)
    at IncomingMessage.emit (events.js:327:22)
    at endReadableNT (_stream_readable.js:1201:12)

For the use case of the tool I was using, it was fixed by replacing:

  apiUrl: 'https://www.toggl.com',
  reportsUrl: 'https://www.toggl.com/reports'

For:

  apiUrl: 'https://track.toggl.com',
  reportsUrl: 'https://track.toggl.com/reports'

in /lib/client.js.

But I don't know if that solution will be fit for all use cases. If that's the case, maybe I could submit a PR with that change as well as updating the udpated URL to the API keys

Maybe this should be pulled into a configuration file instead of hard-coded in case of future URL changes?