-
-
Notifications
You must be signed in to change notification settings - Fork 923
Improve m.request to simplify access response headers #2656
Copy link
Copy link
Closed
Labels
Area: CoreFor anything dealing with Mithril core itselfFor anything dealing with Mithril core itselfType: Breaking ChangeFor any feature request or suggestion that could reasonably break existing codeFor any feature request or suggestion that could reasonably break existing codeType: EnhancementFor any feature request or suggestion that isn't a bug fixFor any feature request or suggestion that isn't a bug fix
Metadata
Metadata
Assignees
Labels
Area: CoreFor anything dealing with Mithril core itselfFor anything dealing with Mithril core itselfType: Breaking ChangeFor any feature request or suggestion that could reasonably break existing codeFor any feature request or suggestion that could reasonably break existing codeType: EnhancementFor any feature request or suggestion that isn't a bug fixFor any feature request or suggestion that isn't a bug fix
Type
Projects
Status
Closed
I was using m.request and I needed to access the response headers to access the etag to get the version of my requested entity to avoid overwriting concurrent changes with an "If-Match" header on my subsequent put request.
While adding headers to a request is easy with the headers option, the only way I could find to access headers was with the extract option. The downside with this approach is that I then had to start handling both the parsing and error handling of the server responses, which is not really germane to what I was trying to accomplish.
A simple approach to resolving this would be to return a slightly more complicated response object, for example, this is what axios returns:
After some discussion about this topic on gitter, there may be other issues that could be improved (e.g., the overlapping nature of deserialize and extract), but I don't have enough experience with Mithril to comment on other improvements too deeply. At a minimum, making headers as easy to read as they are to set, seems like a reasonable enhancement.