Replies: 5 comments
-
You could imagine implementing this in a non-breaking way. For example, add some sort of flag property to the request options to indicate whether you want a "full" response or not and default to sending the current "simple" response. However, I admit that making it a breaking change would result in a cleaner API. |
Beta Was this translation helpful? Give feedback.
-
Keep in mind, multiple prototypes like that would also bloat the bundle size, and that is a concern as well. |
Beta Was this translation helpful? Give feedback.
-
Maybe you can choose to use |
Beta Was this translation helpful? Give feedback.
-
It is not that it isn't possible with m.request(), it is that is is more complicated than it needs to be. I might be able to use fetch(), but if I'm using m.request() everywhere else, then it would be sort of a bummer to have to do it differently in just this one case to access the response headers more easily. However, with that being said, I'm fine if this issue is closed due to lack of interest. |
Beta Was this translation helpful? Give feedback.
-
I faced this problem now too. I would like to use Currently I would need to duplicate this in my custom An interception function parallel to regular behavior |
Beta Was this translation helpful? Give feedback.
-
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.
Beta Was this translation helpful? Give feedback.
All reactions