get method

Future<String> get(
  1. String url, {
  2. RequestParams? requestParams,
  3. bool isTaokeApi = true,
})

发起http请求

url 接口地址

data 查询参数

error 请求错误回传

Implementation

Future<String> get(String url,{RequestParams? requestParams,bool isTaokeApi = true}) async {
  if (isTaokeApi) {
    url = tkApi + url;
  }
  final api = TKBaseApi(url, httpMethod: HttpMethod.get);
  try {
    final r = await api.request(requestParams??const RequestParams());
    return r.getData().whenOrNull(string: (value) => value,json: jsonEncode).ifNullThrowBizException();
  } on BaseApiException catch (_) {
    rethrow;
  }

}