js-algorand-sdk
js-algorand-sdk copied to clipboard
POST and DELETE requests always assume the response is JSON
Problem
Our POST and DELETE request implementations always assume the response is JSON.
More context here: https://github.com/algorand/js-algorand-sdk/pull/749#discussion_r1143845809
Solution
We should improve these handlers to behave like GET, which figures out the response format based on the query parameters for the call, using getAcceptFormat(query).
@jasonpaulos Are the simulate responses available in JSON--so that this is just blocking getting them optionally in msgpack? Or are they only returned in msgpack so that the simulate endpoint is broken for this API because is assumes the response is JSON?
Simulate responses can be returned in either JSON or msgpack, controlled by the format query param. This SDK uses msgpack for the simulation responses.
However this issue isn't a blocker for that workflow, since simulate passes false for the optional parseBody argument to the POST function.
This issue just points out that that's an inconsistency compared to our more popular GET function, which can properly handle both JSON and msgpack responses with parseBody=true.