vc3 / connectwise-rest-api

Nodejs Module for Connectwise's REST API
http://vc3.github.io/connectwise-rest-api
MIT License
11 stars 9 forks source link

timeEntriesIdDelete throws error on success #11

Open sgtoj opened 6 years ago

sgtoj commented 6 years ago

TimeEntriesApi.timeEntriesPost() throws error on success. ConnectWise doesn't return data on DELETE methods. However, it seems some sort of JSON parsing of the body/data is being performed before returning to the requester. You should check for 204 status fore attempting to parse.

Error Message and Stack

FetchError: invalid json response body at https://empire.sw.com/v4_6_release/apis/3.0/time/entries/11316363? reason: Unexpected end of JSON input
    at c:\Users\skywaker\dealth-star-api\node_modules\node-fetch\lib\body.js:48:31
    at <anonymous>
    at process._tickDomainCallback (internal/process/next_tick.js:228:7)
sowderca commented 6 years ago

@sgtoj Do you mean TimeEntriesApi.timeEntriesIdDelete()? If so then yes, thats a bit of an oversight. We shouldn't be attempting to parse something that isn't there. I can alter the DELETE methods to fulfill the promise when returning no content.

sgtoj commented 6 years ago

@sowderca Definitely agree that is what should be done. That is, returning Promise.resolve().