({ state, dispatch, commit }, { componentName, options = {} })
| 299 | // options = { data: {} } |
| 300 | // options.data = {} -> contains specific properties to fetch (or `project`) for an object as a string, eg: {users: 'firstName,lastName,email', levelSessions: 'state.complete,level,creator,changed'} |
| 301 | async fetchData ({ state, dispatch, commit }, { componentName, options = {} }) { |
| 302 | if (!state.teacherId) { |
| 303 | console.error('Error in fetching data: teacherId is not set') |
| 304 | noty({ text: 'Error in fetching data', type: 'error', layout: 'center', timeout: 2000 }) |
| 305 | return |
| 306 | } |
| 307 | |
| 308 | commit('startLoading') |
| 309 | commit('setComponentName', componentName) |
| 310 | const fetchPromises = [] |
| 311 | fetchPromises.push(fetchDataByComponent({ dispatch, state, commit }, { componentName, options })) |
| 312 | await Promise.all(fetchPromises) |
| 313 | }, |
| 314 | |
| 315 | // My classes page |
| 316 | // options.data = { levelSessions: '' } -> properties needed for these objects, i.e. will be used as `project` in db queries |
nothing calls this directly
no test coverage detected