@tuleap/fetch-result
is being progressively adopted as a replacement of @tuleap/tlp-fetch
. However, a pain point has risen with usage of postJSON()
. As it stands, it requires callers to chain it with decodeJSON
manually in order to decode the Response
as a JSON payload. Initially, I thought that we did not have that many POST endpoints answering with a JSON body, but it turns out it's a common pattern. Thus, the library should do it for us. Like for getJSON
, we should provide a generic to type the JSON response we expect to receive. If we don't care about the result, we can always give it unknown
or map the result to void
.
putJSON()
and patchJSON()
are not used yet, so they are not changed. They may also require the same change in the future.
Follow-up of request #26737