daily pastebin goal
70%
SHARE
TWEET

Untitled

a guest Oct 15th, 2018 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // manipulate responseField to render a formatted and appropriate message
  2. const renderResponse = (res) => {
  3.   if(res.errors){
  4.     responseField.innerHTML = "<p>Sorry, couldn't format your URL.</p><p>Try again.</p>"
  5.   } else {
  6.     responseField.innerHTML = `<p>Your shortened url is: </p><p> ${res.shortUrl} </p>`
  7.   }
  8. }
  9.  
  10. // manipulate responseField to render an unformatted response
  11. const renderRawResponse = (res) => {
  12.   if(res.errors){
  13.     responseField.innerHTML = "<p>Sorry, couldn't format your URL.</p><p>Try again.</p>"
  14.   } else {
  15.     let structuredRes = JSON.stringify(res).replace(/,/g, ", \n")
  16.     structuredRes = `<pre>${structuredRes}</pre>`
  17.  
  18.     responseField.innerHTML = `${structuredRes}`
  19.   }
  20. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top