building out back and front end apis
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import type { Sticky } from '../types/types';
|
||||
|
||||
|
||||
const fetchStickies = async () => {
|
||||
const response = await fetch('https://<backend-url>/v1/stickies');
|
||||
const fetchStickies = async (): Promise<Sticky[]> => {
|
||||
const response = await fetch('http://localhost:3001/api/notes');
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
@@ -18,7 +18,7 @@ const fetchStickies = async () => {
|
||||
if (isLoading) return <div>Loading...</div>;
|
||||
if (error) return <div>Error: {error.message}</div>;
|
||||
|
||||
return <div>{data?.map((sticky: any) => <div key={sticky.id}>{sticky.text}</div>)}</div>;
|
||||
return <div>{data?.map((sticky) => <div key={sticky.id}>{sticky.text}</div>)}</div>;
|
||||
};
|
||||
|
||||
export default Stickies;
|
||||
8
frontend/resias/src/types/types.tsx
Normal file
8
frontend/resias/src/types/types.tsx
Normal file
@@ -0,0 +1,8 @@
|
||||
export type Sticky = {
|
||||
id: string;
|
||||
text: string;
|
||||
x: number;
|
||||
y: number;
|
||||
author: string;
|
||||
color: string;
|
||||
};
|
||||
Reference in New Issue
Block a user