REST Service for POPCORN - ILIAS
alex
2025-06-04 7aa80f1c68df586c1bc637c668666d29e84c3de7
vue/src/pages/Users.vue
@@ -4,32 +4,33 @@
import {useRoute} from "vue-router"
import Pagination from "../components/Pagination.vue"
import {getUsers} from "@/lib/api"
import {useRouteQuery} from '@vueuse/router'
const route = useRoute()
const userId = route.params.userId
const users = reactive({
   total: 0,
   offset: 0,
   offset: 0, // NO! USE offset BELOW!
   limit: 10,
   data: [],
})
const offset = useRouteQuery("offset", 0, {transform: Number})
const limit = 24
const error = ref(null)
onMounted(init)
onMounted(() => init(offset.value))
/////////////////////////////////////////////////////////////////////////
async function init (offset = 0) {
   // const res = await fetch(`/api/users?offset=${offset}&limit=${limit}&token=jiuGfr432898D90290kjfsldkfn3hh8F`)
   // const data = await res.json()
   const data = await getUsers(offset, limit)
async function init (noffset = 0) {
   const data = await getUsers(noffset, limit)
   console.log(data)
   Object.assign(users, data)
   offset.value = noffset
}
function go (offset) {
   console.log("go", offset)
   console.log("go to offset", offset)
   return init(offset)
}