diff --git a/public/javascripts/shorten.js b/public/javascripts/shorten.js index add76d2..b0beb67 100644 --- a/public/javascripts/shorten.js +++ b/public/javascripts/shorten.js @@ -1,26 +1,26 @@ -function shorten(){ - $.ajax({ - url: '/api/v1/shorten', - type: 'POST', - dataType: 'JSON', - data: {url: $('#url-field').val()}, - success: function(data){ - console.log('data', data); - const $link = $('#link'); - const resultHTML = `${data.shortUrl}`; - $link.html(resultHTML); - $link.hide().fadeIn('slow'); +function shorten() { + $.ajax({ + url: '/api/v1/shorten', + type: 'POST', + dataType: 'JSON', + data: { url: $('#url-field').val() }, + success: data => { + console.log('data', data); + const $link = $('#link'); + const resultHTML = `${data.shortUrl}`; + $link.html(resultHTML); + $link.hide().fadeIn('slow'); - } - }); + } + }); } -$("#url-field").keyup(function(event){ - if(event.keyCode === 13){ - $("#btn-shorten").click(); - } +$('#url-field').keyup( (event) => { + if(event.keyCode === 13) + $('#btn-shorten').click(); + }); -$('#btn-shorten').on('click', function(){ - shorten(); -}); \ No newline at end of file +$('#btn-shorten').on('click', () => { + shorten(); +});