Skip to content

Commit

Permalink
Prevent double call on token refreshment (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
JEuler authored Oct 10, 2021
1 parent 82b951f commit f7255b7
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions chopper/lib/src/base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,13 @@ class ChopperClient {

if (updatedRequest != null) {
res = await send<BodyType, InnerType>(updatedRequest);
// To prevent double call with typed response
if (_responseIsSuccessful(res.statusCode)) {
return _processResponse(res);
} else {
res = await _handleErrorResponse<BodyType, InnerType>(res);
return _processResponse(res);
}
}
}

Expand All @@ -327,10 +334,13 @@ class ChopperClient {
res = await _handleErrorResponse<BodyType, InnerType>(res);
}

res = await _interceptResponse<BodyType, InnerType>(res);
return _processResponse(res);
}

Future<Response<BodyType>> _processResponse<BodyType, InnerType>(
dynamic res) async {
res = await _interceptResponse<BodyType, InnerType>(res);
_responseController.add(res);

return res;
}

Expand Down

0 comments on commit f7255b7

Please sign in to comment.