added vue component
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<script setup>
|
||||
import { ref, onMounted } from 'vue';
|
||||
import axios from 'axios';
|
||||
|
||||
const feeds = ref([]);
|
||||
|
||||
const fetchData = async () => {
|
||||
try {
|
||||
const response = await axios.get('feeds', {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'user-token': localStorage.getItem("user-token")
|
||||
}
|
||||
});
|
||||
feeds.value = response.data.feeds[0].items;
|
||||
} catch (error) {
|
||||
console.error('Error fetching data:', error);
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
fetchData();
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<h1>Feeds</h1>
|
||||
<div id='aricle'>
|
||||
<template v-for="feed in feeds">
|
||||
<h2>{{ feed.title }}</h2>
|
||||
<p v-html='feed.content'></p>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user