Skip to content

Instantly share code, notes, and snippets.

@anitaa1990
Created November 20, 2024 11:17
Show Gist options
  • Select an option

  • Save anitaa1990/35794a044341e92d315953e41dd41406 to your computer and use it in GitHub Desktop.

Select an option

Save anitaa1990/35794a044341e92d315953e41dd41406 to your computer and use it in GitHub Desktop.
class NewsRepository @Inject constructor(
private val apiService: NewsApiService
) {
suspend fun fetchNews(
query: String,
nextPage: Long
): NewsApiResponse {
return try {
apiService.fetchFeed(
q = query,
apiKey = BuildConfig.api_key,
pageSize = PAGE_SIZE,
page = nextPage
)
} catch (e: Exception) {
e.printStackTrace()
throw Exception(e)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment