onRequest method

  1. @override
void onRequest(
  1. RequestOptions options,
  2. RequestInterceptorHandler handler
)

Called when the request is about to be sent.

Implementation

@override
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
  // 设置公共请求头
  publicHeaders.forEach((key, value) {
    options.headers[key] = value;
  });

  // 设置公共请求参数,虽然不推荐,就怕有人不按规范搞
  publicQueryParams.forEach((key, value) {
    options.queryParameters[key] = value;
  });
  super.onRequest(options, handler);
}