[英]Why ransack doesn't work with flutter chopper?
我的 flutter 项目使用斩波器调用 api 服务器,其中服务器端使用Rails
编写。
服务.dart
@Post(path: "orders_list")
Future<Response> getOrderList(@Field('token') String authToken, @Field('q[flow_gteq_any]') int flow,
@Field('q[flow_lteq_any]') int flow2);
我希望服务器根据flow_gteq_any
和flow_lteq_any
返回数据,但它会将所有数据返回给我。
这就是我调用getOrderList
function 的地方。
存储库
Future<Response> getWorkOrderList(String authToken) async{
Response response;
try{
response = await _service.getOrderList(authToken,100,197);
return response;
}catch (e) {
print('Caught ${e.body}');
rethrow;
}
}
我没有使用 flutter、chopper 或 ransack 的经验,但我在 android native 中使用了Retrofit2
,它看起来类似于 chopper。
从您的评论中,您提到通过指定的 URL 调用服务是有效的,但代码片段显示您使用的是 POST 而不是 GET。
从可以在此处找到的示例中,也许您应该尝试将代码更改为类似
@Get(path: '/orders_list')
Future<Response> getOrderList(@Query('token') String authToken, @Query('q[flow_gteq_any]') int flow, @Query('q[flow_lteq_any]') int flow2);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.