// fetch with promisefetch("/api/test",{method:"GET"}).then((response)=>{console.log("Connected");returnresponse.json();}).then((data)=>{console.log("Data received.");// do something with data}).catch((error)=>{console.log("Error: "+error);});// fetch with async/awaitfetchAsync=async()=>{try{constresponse=awaitfetch("/api/test",{method:"GET"});if(!response.ok){console.log("HTTP error! status: "+response.status);}else{constdata=awaitresponse.json();console.log("Data received.");// do something with data}}catch(error){console.log("Error: "+error);}};