File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ let lastIdSeen = -1;
33async function getAllMessages ( ) {
44 try {
55 const response = await fetch (
6- `http ://localhost:3000 /messages?since=${ lastIdSeen } ` ,
6+ `https ://iswanna-chat-app-backend.onrender.com /messages?since=${ lastIdSeen } ` ,
77 ) ;
88
99 const data = await response . json ( ) ;
@@ -41,9 +41,12 @@ async function getAllMessages() {
4141 likeButton . textContent = "Like" ;
4242
4343 likeButton . addEventListener ( "click" , async ( ) => {
44- await fetch ( `http://localhost:3000/messages/${ message . id } /like` , {
45- method : "POST" ,
46- } ) ;
44+ await fetch (
45+ `https://iswanna-chat-app-backend.onrender.com/messages/${ message . id } /like` ,
46+ {
47+ method : "POST" ,
48+ } ,
49+ ) ;
4750 } ) ;
4851
4952 // put it all together
@@ -76,16 +79,19 @@ formElement.addEventListener("submit", async (event) => {
7679
7780 try {
7881 // Send the data
79- const response = await fetch ( "http://localhost:3000/messages" , {
80- method : "POST" ,
81- headers : {
82- "Content-Type" : "application/json" ,
82+ const response = await fetch (
83+ "https://iswanna-chat-app-backend.onrender.com/messages" ,
84+ {
85+ method : "POST" ,
86+ headers : {
87+ "Content-Type" : "application/json" ,
88+ } ,
89+ body : JSON . stringify ( {
90+ sender : senderValue ,
91+ text : messageValue ,
92+ } ) ,
8393 } ,
84- body : JSON . stringify ( {
85- sender : senderValue ,
86- text : messageValue ,
87- } ) ,
88- } ) ;
94+ ) ;
8995
9096 if ( response . ok ) {
9197 // clear the sender and message input values
You can’t perform that action at this time.
0 commit comments