-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make it possible to get request method from error object #265
Comments
Hello, as you use URL string to make request, context will contain request as string. $fetch(new Request('http://api.com/post', {
method: 'post',
body: JSON.stringify({})
}), {
// those will be overridden by Request object, even if not specified in Request object
method: 'post',
body: {
}
}) example codesandbox |
I would like to suggest adding the |
@KaKi87 |
Actually, I was only making this suggestion to solve OP's request. Personally, I don't have such a use case. But, since Axios provides this as well, I suppose it can be useful. Thanks |
oh yeah that totally makes sense now
they don't advertise it much to be honest for the record, I need this feature for logging purposes, I am migrating some library from logging the endpoint and returned body might not be enough given that the same endpoint will not do the same thing when requested with GET, PUT or POST. thank you for your answer, I am marking this as resolved. |
I think this issue should remain open because the |
I do agree. As @KaKi87 said, it kind of eradicates the whole point of using I took a quick glance at the code and I think Another (better) solution would be to simply use what I mean is that whenever a string is passed as the first argument, it gets turned into a I am still willing to PR this if you feel like this is a valuable thing like I do, it's also pretty easy. |
simply put, the codebase is built in such a way that when the promise is resolved, there is no access to the request options. |
looking for that too |
Should be supported via |
thanks! |
Describe the feature
Is there a workaround ?
Am I doing this the wrong way around ?
The issue here is that
FetchRequest
's type boils down tostring | Request
, and astring
is being returned, which is rather unhelpful when you also need to access other properties from the request object.Additional information
The text was updated successfully, but these errors were encountered: