const url = 'https://api.ceojuice.com/api/Processes/SurveyComments?CustomerNumber=071&AuthKey=f3a1c47d-a2ae-4a53-b290-5f953cb87503&qty=10' const testimonials = document.getElementById('testimonials') fetch(url) .then((res) => res.json()) .then((json) => { const testimonialsByDate = json.sort((a, b) => new Date(b.responseDate) - new Date(a.responseDate)) testimonialsByDate.forEach((testimonial) => { testimonials.innerHTML += `
${testimonial.comment}${testimonial.contact}
${new Date(testimonial.responseDate).toLocaleDateString()}
` }) }) .catch((err) => { throw err })