@@ -28,13 +28,9 @@ export const useItemsStore = defineStore('items', {
2828 ordering : undefined ,
2929 } ) ,
3030 actions : {
31- async retrieveItems ( $axios , apiUrl = undefined , params = { } ) {
31+ async retrieveItems ( $axios , apiUrl = undefined , params = { } , cache = true ) {
3232 const cacheName = apiCacheName ( apiUrl , params )
3333 // Would be nice to amke ordering dynamic as a parameter, perhaps one day
34- // let ordering = "-updated_date"
35- // if (apiUrl.indexOf("/people/") !== -1)
36- // ordering = "first_name"
37- // check if params has "limit", "order" or "offset" and use them instead of the default ones
3834 if ( ! ( "limit" in params ) )
3935 params . limit = this . pageSize
4036 if ( ! ( "offset" in params ) )
@@ -49,10 +45,14 @@ export const useItemsStore = defineStore('items', {
4945 }
5046 apiUrl += "?" + new URLSearchParams ( params ) . toString ( )
5147
52- this . items [ cacheName ] = ( await $axios . get ( apiUrl , { 'headers' : authHeaders ( ) } ) ) . data
53- if ( Array . isArray ( this . items [ cacheName ] ) ) { // When the endpoint is not paginated
54- this . items [ cacheName ] = { results : this . items [ cacheName ] }
48+ let res = ( await $axios . get ( apiUrl , { 'headers' : authHeaders ( ) } ) ) . data
49+ if ( Array . isArray ( res ) ) { // When the endpoint is not paginated
50+ res = { results : res }
5551 }
52+ if ( ! cache )
53+ return res
54+
55+ this . items [ cacheName ] = res
5656 return this . items [ cacheName ]
5757 } ,
5858 async deleteItem ( $axios , apiUrl , id ) {
0 commit comments