Networking icon indicating copy to clipboard operation
Networking copied to clipboard

Can't get response codes as a consumer

Open mwiggins-casa opened this issue 2 years ago • 2 comments

I'd like to be able to be able to get the API response code returned from calls (post, get, put, ...). This would allow me to use the response code in order to make decisions depending on the type of response (200 vs 201, etc.).

I've got some ideas around how to accomplish this and can open a draft PR

mwiggins-casa avatar Jan 25 '23 15:01 mwiggins-casa

Hey @mwiggins-casa, good call, indeed at the moment we can only get the response codes for errors, but not for successful calls. I just realized this recently and this is definitely something we need :) Possible solutions that come to my mind would be to have a variant for get post/ put calls that returns a tuple (a,b) a being the ResponseData or status code and B the T:Decodable model. One other way would be to to have a NetworkingResponse variant that would have the mapped model inside for example.

Feel free to open a PR, contributions are always welcome of course. And also feel free to reach out if you want help/feedback or just discuss the api.

Thanks!

s4cha avatar Jan 25 '23 17:01 s4cha

Hey @s4cha sounds good, thanks - the tuple approach is along the lines of my initial thoughts, I'll give it a shot over the next couple days.

mwiggins-casa avatar Jan 25 '23 17:01 mwiggins-casa