onRequest method
- @override
override
The callback will be executed before the request is initiated.
If you want to resolve the request with some custom data,
you can return a Response object or return dio.resolve
.
If you want to reject the request with a error message,
you can return a DioError object or return dio.reject
.
If you want to continue the request, return the Options object.
Implementation
@override
onRequest(RequestOptions options) async {
final token = await _tokenStore.fromStore();
options.headers["Authorization"] = "Bearer ${token.accessToken}";
return options;
}