Change get articles to read from database instead of dummy data.

This commit is contained in:
2023-10-14 18:32:49 +02:00
parent c8ca91e90b
commit 3d77c6f30f
11 changed files with 157 additions and 61 deletions
+4 -2
View File
@@ -6,8 +6,9 @@ const feeds = ref([]);
const buttonText = 'Sync'
const fetchData = async () => {
const user_id = localStorage.getItem("user-id")
try {
const response = await axios.get('feeds/get', {
const response = await axios.get("feeds/get/" + user_id, {
headers: {
'Content-Type': 'application/json',
'user-token': localStorage.getItem("user-token")
@@ -22,7 +23,7 @@ const fetchData = async () => {
async function sync() {
try {
const repsponse = await axios.post('feeds/sync', {
user_id: localStorage.getItem("user-id")
user_id: 1 //localStorage.getItem("user-id")
},
{
headers: {
@@ -46,6 +47,7 @@ onMounted(() => {
<div>
<h1>Feeds</h1> <button @click="sync">{{ buttonText }}</button>
<div id='aricle'>
<p v-if="feeds.length == 0">No unread articles.</p>
<template v-for="feed in feeds">
<h2>{{ feed.title }}</h2>
<p v-html='feed.content'></p>