-
Notifications
You must be signed in to change notification settings - Fork 0
/
projet-vuejs.html
66 lines (59 loc) · 1.42 KB
/
projet-vuejs.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
<title>Basic API GET in vuejs</title>
<style>
#project {
font-family: 'Roboto', sans-serif;
}
li {
margin-bottom: 2cm;
}
</style>
</head>
<body>
<div id="project">
<!-- <pre>{{commits}}</pre> -->
<h1>Articles</h1>
<ul>
<li v-for="(dataset, index) in datasets">
<h2>Article {{ index }}</h2>
<h3>{{ dataset.metas.title }}</h3>
<p v-html="dataset.metas.description">{{ dataset.metas.description }}</p>
</li>
</ul>
</div>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="https://unpkg.com/vue@3"></script>
<script>
const apiURL =
"https://data.nantesmetropole.fr/api/datasets/1.0/search/?q=&rows=10";
Vue.createApp({
data() {
return {
datasets: null,
};
},
created: function () {
this.fetchDataAsync();
},
methods: {
fetchDataAsync: async function () {
try {
const response = await axios.get(apiURL)
console.log(response.data)
this.datasets = response.data.datasets
// console.log(self.commits[0].html_url);
} catch (error) {
console.log(error);
}
}
},
}).mount("#project");
</script>
</body>
</html>