Skip to content

Commit 1fdf5d4

Browse files
committed
L5 ending with comments
1 parent 8c6d134 commit 1fdf5d4

File tree

4 files changed

+42
-37
lines changed

4 files changed

+42
-37
lines changed

package-lock.json

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"@vue/cli-service": "~4.5.0",
2222
"@vue/compiler-sfc": "^3.0.0-0",
2323
"@vue/eslint-config-prettier": "^6.0.0",
24+
"axios": "^0.20.0",
2425
"babel-eslint": "^10.1.0",
2526
"eslint": "^6.7.2",
2627
"eslint-plugin-prettier": "^3.1.3",

src/services/EventService.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import axios from 'axios'
2+
3+
const apiClient = axios.create({
4+
baseURL: 'https://my-json-server.typicode.com/Code-Pop/Real-World_Vue-3',
5+
withCredentials: false,
6+
headers: {
7+
Accept: 'application/json',
8+
'Content-Type': 'application/json'
9+
}
10+
})
11+
12+
export default {
13+
getEvents() {
14+
return apiClient.get('/events')
15+
}
16+
}

src/views/EventList.vue

Lines changed: 16 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -5,52 +5,31 @@
55
</template>
66

77
<script>
8-
// @ is an alias to /src
98
import EventCard from '@/components/EventCard.vue'
9+
import EventService from '@/services/EventService.js'
10+
// import axios from 'axios'
1011
1112
export default {
12-
name: 'Home',
13+
name: 'EventList',
1314
components: {
1415
EventCard
1516
},
1617
data() {
1718
return {
18-
events: [
19-
{
20-
id: 5928101,
21-
category: 'animal welfare',
22-
title: 'Cat Adoption Day',
23-
description: 'Find your new feline friend at this event.',
24-
location: 'Meow Town',
25-
date: 'January 28, 2022',
26-
time: '12:00',
27-
petsAllowed: true,
28-
organizer: 'Kat Laydee'
29-
},
30-
{
31-
id: 4582797,
32-
category: 'food',
33-
title: 'Community Gardening',
34-
description: 'Join us as we tend to the community edible plants.',
35-
location: 'Flora City',
36-
date: 'March 14, 2022',
37-
time: '10:00',
38-
petsAllowed: true,
39-
organizer: 'Fern Pollin'
40-
},
41-
{
42-
id: 8419988,
43-
category: 'sustainability',
44-
title: 'Beach Cleanup',
45-
description: 'Help pick up trash along the shore.',
46-
location: 'Playa Del Carmen',
47-
date: 'July 22, 2022',
48-
time: '11:00',
49-
petsAllowed: false,
50-
organizer: 'Carey Wales'
51-
}
52-
]
19+
events: null
5320
}
21+
},
22+
created() {
23+
EventService.getEvents()
24+
// .get(
25+
// 'https://my-json-server.typicode.com/Code-Pop/Real-World_Vue-3/events'
26+
// )
27+
.then(response => {
28+
this.events = response.data
29+
})
30+
.catch(error => {
31+
console.log(error)
32+
})
5433
}
5534
}
5635
</script>

0 commit comments

Comments
 (0)