Tasks: able to get and print tasks

This commit is contained in:
2023-12-31 01:39:42 +01:00
parent cf20935e01
commit 4c9765b4a3
10 changed files with 103 additions and 24 deletions

View File

@@ -1,4 +1,5 @@
export default {
api_url: 'http://localhost:6060/api/v1',
data: {
user: {
_id: '1234',
@@ -7,26 +8,28 @@ export default {
},
newTask: {},
fetchedTasks: [
{
_id: 1,
title: 'frontend',
project: 'TiM',
client: 'Filip Rojek',
timeStart: 1703960133061,
timeEnd: 1703960141414
},
{
_id: 2,
title: 'setting up',
project: 'l2tp vpn',
client: 'IS Media',
timeStart: 1703960133061,
timeEnd: 1703960141414
}
//{
// _id: 1,
// title: 'Loading',
// project: 'Loading',
// client: 'Loading',
// timeStart: 1703960133061,
// timeEnd: 1703960141414
//}
]
},
// Methods that you need, for e.g fetching data from server etc.
fetchData() {
// fetch logic
async fetchData() {
try {
const response = await fetch(this.api_url + '/task/get')
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`)
}
const data = await response.json()
this.data.fetchedTasks = data
console.log('Received data:', data)
} catch (error) {
console.error('Error fetching data:', error)
}
}
}