twitch-cli icon indicating copy to clipboard operation
twitch-cli copied to clipboard

Don't make data object an empty array on error

Open Dkamps18 opened this issue 3 months ago • 0 comments

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Problem/Feature

Historically when the API returned an error the CLI would include a data array in the json response being printed out, however this data array is not returned from the api. API response

{
	"error": "Not Found",
	"message": "404: Not Found",
	"status": 404
}

CLI Output

{
	"data": [],
	"error": "Not Found",
	"message": "404: Not Found",
	"status": 404
}

Description of Changes:

  • Don't initialize an array when data is nil and there is an error message

Checklist

  • [x] My code follows the Contribution Guide
  • [x] I have self-reviewed the changes being requested
  • [x] I have made comments on pieces of code that may be difficult to understand for other editors
  • [x] I have updated the documentation (if applicable)

Dkamps18 avatar Sep 16 '25 17:09 Dkamps18