REST Service for POPCORN - ILIAS
alex
2025-06-03 cf487abef43e9c8a1651daa306383cb7170eefc0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<script setup>
 
import {onMounted, reactive, ref} from "vue"
import {useRoute} from "vue-router"
 
const route = useRoute()
const userId = route.params.userId
const users = reactive({
   total: 0,
   offset: 0,
   limit: 10,
   data: [],
})
const error = ref(null)
 
onMounted(init)
 
/////////////////////////////////////////////////////////////////////////
 
async function init () {
   const res = await fetch(`/api/users?token=jiuGfr432898D90290kjfsldkfn3hh8F`)
   const data = await res.json()
   console.log(data)
   if (res.status === 200) {
      Object.assign(users,data)
   }
   else {
      error.value = `ERROR: ${res.status}`
   }
}
 
</script>
 
<template>
 
   <div>
 
      <h1>Users</h1>
      <p>{{ userId }}</p>
      <p v-if="error">{{ error }}</p>
 
      <div class="users">
         <table class="">
            <thead>
               <tr>
                  <th>usr_id</th>
                  <th>login</th>
                  <th>firstname</th>
                  <th>lastname</th>
                  <th>gender</th>
                  <th>email</th>
                  <th>institution</th>
                  <th>department</th>
               </tr>
            </thead>
            <tbody>
               <tr v-for="user in users.data">
                  <td>{{user.usr_id}}</td>
                  <td>{{user.login}}</td>
                  <td>{{user.firstname}}</td>
                  <td>{{user.lastname}}</td>
                  <td>{{user.gender}}</td>
                  <td>{{user.email}}</td>
                  <td>{{user.institution}}</td>
                  <td>{{user.department}}</td>
               </tr>
            </tbody>
         </table>
      </div>
 
      <pre>{{ users }}</pre>
   </div>
 
</template>
 
<style scoped>
 
</style>