-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Fixed: update in example/lib/queued_interceptor_csrftoken.dart #1262
Conversation
Hi @seunghwanly, now |
@AlexV525 |
We're planning to merge valid PRs to another community-maintained fork, so it would be great if you can follow up the upstream changes. |
Oh if you make force pushes on the |
Yeah, I thought the example I pushed is not suitable from now on... Let me add some examples for |
New Pull Request Checklist
Pull Request DescriptionSummary
Issues
// If the token has been updated, repeat directly.
if (csrfToken != options.headers['csrfToken']) {
options.headers['csrfToken'] = csrfToken;
//repeat
dio.fetch(options).then(
(r) => handler.resolve(r),
onError: (e) {
handler.reject(e);
},
);
return;
} Opinion
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the update!
dio/lib/src/response.dart
Outdated
/// Returns if the response has an error | ||
/// | ||
/// `hasError` is true when status code is not between 200 and 299 | ||
bool get hasError => statusCode != null && statusCode! ~/ 100 != 2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC we have ValidateStatus
as a prediction, it might be inappropriate to use such a getter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought it would be nice to have the getter direct to the Response
object, but if it is an appropriate way I'll remove the getter. Thanks :)
#1457 is trying to solve the issue by refactoring the interceptor in the example. Can you verify if both fixes are valid or which should we apply? |
I've seen the #1457 pull request and I think we have both valid fixes. Since we are assuming the same way as below {
"data": {
"token": "valid token"
}
} and in my opinion, it needs some changes like
and also I think the examples should be easy to read and understand as well so that new comers can adjust and implement their codes. |
Great. Given your reply I would like to pick your PR first, then we can continue to discuss another one if it gets more feedback. |
since `dio` has a `ValidateStatus` as a prediction, it's inappropriate methods.
Glad to hear that :) I removed the getter methods as well. |
We need to fix these before merge.
|
Sorry, I forgot to remove the getter method in the example. Thanks for the notice! |
Hi @seunghwanly. We've made our hardfork repo public and published a new version of |
Thanks for letting me know :) Good to hear that more future jobs will be taken at diox library! |
No. :) Thanks again for your contribution. |
New Pull Request Checklist
This merge request fixes / refers to the following issues: example/interceptor_lock.dart
Pull Request Description
In my case, the example code had keep occurring the infinite requests to the server
So, I changed the callback functions to
await
and it worked :)Here is the code that I run
options
onRequest
, if the token is nullonError
, if the status code is 401Summary
What I recommend is that avoid using too many callback functions in a single task
I think nested callback functions can occur some conflicts and are hard to debug as well 👍