If inside my route handler, I return a json object like this:
return { items: findItemById(idParam) }
it works fine, as long as findItemById()
actually finds something.
When it doesn’t, I’m essentially creating a response payload like { items: undefined }
or maybe { items: null }
, and fastify seems to be stripping out the attribute entirely and returning { }
.
While I could write my own checks for this (I actually would like to return { items: [] }
in such cases), I just wondered: is there a setting that automatically takes care of that? Or a setting which switches off the suppression of falsey values? Thx.