an error pops up: No value passed for parameter ‘serviceId’.
class ServicesViewModel : ViewModel() {
private val repository = SmsRepository()
val services = MutableLiveData<List<Service>>()
val error = MutableLiveData<String>()
fun loadServices() {
viewModelScope.launch {
try {
**services.value = repository.getServices()** [enter image description here][1]
} catch (e: Exception) {
error.value = "Error: ${e.message}"
}
}
}
}
class CountriesViewModel : ViewModel() {
private val repository = SmsRepository()
val countries = MutableLiveData<List<Country>>()
val error = MutableLiveData<String>()
fun loadCountries(serviceId: String) {
viewModelScope.launch {
try {
countries.value = repository.getCountries(serviceId)
} catch (e: Exception) {
error.value = "Error loading countries: ${e.message}"
}
}
link to the entire repository:
https://github.com/Karakom/appd2/tree/master/app/src
[1]: https://i.sstatic.net/A2uJb5J8.png