Jaguar-dart / client

Contains various packages for client side
46 stars 22 forks source link

Basic auth #51

Open salhugues opened 5 years ago

salhugues commented 5 years ago

Hello, I'm looking for an example to add basicauth for my request I haven't found an example on the net for jaguar_ retrofit if somebody can help me.

Here's is my request for my api but I don't know how can I add header and pass basic auth.

class MyApi  extends ApiClient with _$MyApiClient {

  final resty.Route base;
  MyApi(this.base);

  @GetReq(path: "json/works")
  Future<List<MyApiObject>> fetchWorks();

  @GetReq(path: "json/editos")
  Future<List<MyApiObject>> fetchEditos();
}

// My Api Factory
MyApi getMyApi() {

    globalClient = IOClient();
    final repo =
    JsonRepo()
      ..add(MyApiObjectSerializer())
      ..add(UndListSerializer())
      ..add(UndSerializer()); // Don't forget to add all Serializer

    return MyApi(route(StringResources.MY_API_BASE_URL))..jsonConverter = repo;
  }

Thanks for your help.