rbi-learning / Today-I-Learned

1 stars 0 forks source link

Today I learned 8.12 #121

Open dnaqvi opened 4 years ago

dnaqvi commented 4 years ago

Array & Object Methods

Connecting front end to the back end The code below sends the information to our server from the website. Note that the "stringify" method turns whatever we are sending through the web into a string (necessary to successfully send things over the web).

const response = await fetch(url) method: "POST" (or other html verb) headers: { 'Content-Type': application/json', 'Accept': application/json' }, body: JSON.stringify({description: form.description.value}) })

To connect our back end to our front end, we needed to insert reference to the task.id into our html string that lives in the "renderTask" function (see interpolation below).

const html = `

  • `