title: Google Guide to app architecture suspend function error
body: <p>I am using google guide to build architecture(<a href="https://developer.android.com/jetpack/guide" rel="nofollow noreferrer">https://developer.android.com/jetpack/guide</a>) for my new android app. But when I am using Flow to return data from room database as mentioned above there is something unexpected :</p>
  <pre><code>   @HiltViewModel
     class CategoriesViewModel @Inject constructor(categoriesRepository:CategoriesRepository) : ViewModel() {
           var categories : LiveData&lt;List&lt;Category&gt;&gt; = 
               categoriesRepository.getCategories().asLiveData()
     }
  
  
     class CategoriesRepository @Inject constructor(val categoryDao: CategoryDao) {
  
     suspend fun getCategories(): Flow&lt;List&lt;Category&gt;&gt; {
         refreshCategories()
        // Returns a Flow object directly from the database.
        return categoryDao.getAll()
     }
  
     private suspend fun refreshCategories() {
        val response = ApiInterface.create().getCategories()
        categoryDao.insertAll(response.data!!)
     }
     }
  </code></pre>
  <p>The error is : Suspend function 'getCategories' should be called only from a coroutine or another suspend function.
  But in the guide these functions are suspend functions.
  How to fix this error?</p>