oh well 3d35b681
Steve · 2024-09-22 15:23 1 file(s) · +13 −8
src/components/GuestbookFeed.tsx +13 −8
26 26
	async function fetchMessages() {
27 27
		setIsLoading(true);
28 28
		try {
29 -
			const req = await fetch(`${process.env.PUBLIC_API_URL}/messages`);
29 +
			const req = await fetch(
30 +
				"https://guestbook-db-production.up.railway.app/messages",
31 +
			);
30 32
			const res = await req.json();
31 33
			console.log(res);
32 34
			setMessages(res);
43 45
44 46
	async function sendMessage() {
45 47
		try {
46 -
			const req = await fetch(`${process.env.PUBLIC_API_URL}/messages`, {
47 -
				method: "POST",
48 -
				headers: {
49 -
					Authorization: `Bearer ${await session.getToken()}`,
48 +
			const req = await fetch(
49 +
				"https://guestbook-db-production.up.railway.app/messages",
50 +
				{
51 +
					method: "POST",
52 +
					headers: {
53 +
						Authorization: `Bearer ${await session.getToken()}`,
54 +
					},
55 +
					body: JSON.stringify({ note: inputText }),
50 56
				},
51 -
				body: JSON.stringify({ note: inputText }),
52 -
			});
57 +
			);
53 58
			const res = await req.json();
54 59
			console.log(res);
55 60
			setInputText("");
62 67
	async function deleteMessage(id: number) {
63 68
		try {
64 69
			const req = await fetch(
65 -
				`${import.meta.env.PUBLIC_API_URL}/messages/${id}`,
70 +
				`https://guestbook-db-production.up.railway.app/messages/${id}`,
66 71
				{
67 72
					method: "DELETE",
68 73
					headers: {