chore(services): let getAll
: always return Model[]
This commit is contained in:
parent
5f9485414b
commit
6aa02e29b1
@ -311,7 +311,7 @@ export default abstract class AbstractService<Model extends IAbstract = IAbstrac
|
||||
* @param params Optional query parameters
|
||||
* @param page The page to get
|
||||
*/
|
||||
async getAll(model : Model = new AbstractModel({}), params = {}, page = 1) {
|
||||
async getAll(model : Model = new AbstractModel({}), params = {}, page = 1): Promise<Model[]> {
|
||||
if (this.paths.getAll === '') {
|
||||
throw new Error('This model is not able to get data.')
|
||||
}
|
||||
@ -331,10 +331,7 @@ export default abstract class AbstractService<Model extends IAbstract = IAbstrac
|
||||
return []
|
||||
}
|
||||
|
||||
if (Array.isArray(response.data)) {
|
||||
return response.data.map(entry => this.modelGetAllFactory(entry))
|
||||
}
|
||||
return this.modelGetAllFactory(response.data)
|
||||
} finally {
|
||||
cancel()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user