File tree Expand file tree Collapse file tree 1 file changed +1
-32
lines changed
Expand file tree Collapse file tree 1 file changed +1
-32
lines changed Original file line number Diff line number Diff line change @@ -71,42 +71,11 @@ <h3 class="text-lg font-semibold">Your Short URL</h3>
7171
7272 < script >
7373 const form = document . getElementById ( "shortenForm" ) ;
74- const resultDiv = document . getElementById ( "result" ) ;
75- const shortUrlElement = document . getElementById ( "shortUrl" ) ;
76- const copyBtn = document . getElementById ( "copyBtn" ) ;
7774
7875 form . addEventListener ( "submit" , async ( e ) => {
7976 e . preventDefault ( ) ;
8077
81- const originalUrl = document . getElementById ( "originalUrl" ) . value ;
82- const customAlias = document . getElementById ( "customAlias" ) . value ;
83-
84- const response = await fetch ( "/api/shorten" , {
85- method : "POST" ,
86- headers : {
87- "Content-Type" : "application/json" ,
88- } ,
89- body : JSON . stringify ( {
90- originalUrl,
91- customAlias,
92- } ) ,
93- } ) ;
94-
95- const data = await response . json ( ) ;
96-
97- if ( response . ok ) {
98- resultDiv . classList . remove ( "hidden" ) ;
99- shortUrlElement . textContent = data . shortUrl ;
100- } else {
101- alert ( data . error || "Something went wrong!" ) ;
102- }
103- } ) ;
104-
105- copyBtn . addEventListener ( "click" , ( ) => {
106- const url = shortUrlElement . textContent ;
107- navigator . clipboard . writeText ( url ) . then ( ( ) => {
108- alert ( "URL copied to clipboard!" ) ;
109- } ) ;
78+ alert ( 'received URL(This is a Demo, the app would now give you the shortened Url below the form with a copy button)' ) ;
11079 } ) ;
11180 </ script >
11281</ body >
You can’t perform that action at this time.
0 commit comments