Skip to content

Instantly share code, notes, and snippets.

@shekhargulati
Created November 16, 2019 16:48
Show Gist options
  • Save shekhargulati/6e4224149abaf7638b427d2f9d4d58b3 to your computer and use it in GitHub Desktop.
Save shekhargulati/6e4224149abaf7638b427d2f9d4d58b3 to your computer and use it in GitHub Desktop.
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
public class RetrofitExample {
public static void main(String[] args) throws IOException {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://api.github.com/")
.addConverterFactory(GsonConverterFactory.create())
.build();
GitHubService gitHubService = retrofit.create(GitHubService.class);
Call<List<Repo>> reposCall = gitHubService.listRepos("shekhargulati");
Response<List<Repo>> response = reposCall.execute();
response.body().forEach(System.out::println);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment