•  
      request #28266 postJSON should decode JSON response
    Infos
    #28266
    Joris MASSON (jmasson)
    2022-09-08 15:45
    2022-09-01 11:31
    29820
    Details
    postJSON should decode JSON response

    @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

    Dev tools
    Empty
    Empty
    • [ ] enhancement
    • [x] internal improvement
    Empty
    Stage
    Joris MASSON (jmasson)
    Closed
    2022-09-08
    Attachments
    Empty
    References

    Follow-ups