-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnewsData.js
46 lines (38 loc) · 1.21 KB
/
newsData.js
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
const app = Vue.createApp({
data() {
return {
message: 'Hello Vue!',
newsData: [],
tempData: '',
}
},
methods: {
getNews() {
axios.get('https://hex-escape-room.herokuapp.com/api/cors/news')
.then((res) => {
this.newsData = res.data.data;
this.newsData.forEach((item) => {
item.publishedAt = moment(item.publishedAt).format('YYYY/MM/DD a h:mm:ss ');
}
);
})
.catch((error) => {
console.dir(error)
})
},
getOneNews(id) {
axios.get(`https://alicia-cors-anywhere.herokuapp.com/https://hex-escape-room.herokuapp.com/api/cors/news/${id}`)
.then((res) => {
this.tempData = res.data.data;
this.tempData.publishedAt = moment(this.tempData.publishedAt).format('YYYY/MM/DD a h:mm:ss ');
})
.catch((error) => {
console.dir(error)
})
}
},
mounted() {
this.getNews();
},
});
app.mount('#app')