CodingAleCR / http_interceptor

A lightweight, simple plugin that allows you to intercept request and response objects and modify them if desired.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How should i handle shouldInterceptRequest when you have interceptRequest

charlo2433 opened this issue · comments

commented

Do you have a question regarding how to use the plugin? Please describe.
A clear and concise description of what the question is. Ex. How do I retry a request? [...]

@OverRide
Future interceptRequest({required BaseRequest request}) async{
try {
var token = await GetStorage().read('token');
request.headers["Content-type"] = "application/json";
request.headers["Accept"] = "application/json";
request.headers["Authorization"] = "Bearer " + token;
} catch (e) {
print(e);
}

return request;

}

@OverRide
Future shouldInterceptRequest() {
// TODO: implement shouldInterceptRequest

throw true;
}