From 046b50942d853eb12fd22b6be785d64723ae4e88 Mon Sep 17 00:00:00 2001 From: Astrian Zheng Date: Mon, 30 Jun 2025 16:36:43 +1000 Subject: [PATCH] feat: fetch feed entries and display to user --- app/feed_list.tsx | 53 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/app/feed_list.tsx b/app/feed_list.tsx index 38bed56..df8d51d 100644 --- a/app/feed_list.tsx +++ b/app/feed_list.tsx @@ -1,8 +1,55 @@ -import { View } from 'react-native' +import { View, Text, StyleSheet, ScrollView } from 'react-native' +import { useEffect, useState } from 'react' +import axios from 'axios' +import { useAuthStore } from '../store' + +const Separator = () => + +const styles = StyleSheet.create({ + separator: { + marginVertical: 8, + borderBottomColor: '#cccccc', + borderBottomWidth: 1 + }, + entryItem: { + padding: 16 + } +}) export default function FeedListView() { + const { credential } = useAuthStore() + const [entries, setEntries] = useState([]) + + useEffect(() => { + console.log(credential) + if (!credential) return + + fetchList() + }, []) + + async function fetchList() { + try { + const res = await axios.get("https://api.feedbin.com/v2/entries.json", { auth: credential }) + const entriesRes = res.data as Entry[] + setEntries(entriesRes) + console.log(entries) + } catch (e) { + console.log("`fetchList has an error`") + console.log(e) + } + } + return ( - - + + { entries.length > 0 ? + entries.map(entry => + + {entry.title} + {entry.author} + + + ) + : No entries } + ) }