Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save davidystephenson/561f092ce61d5f61df6ca86093466e2c to your computer and use it in GitHub Desktop.

Select an option

Save davidystephenson/561f092ce61d5f61df6ca86093466e2c to your computer and use it in GitHub Desktop.
async function getCategories () {
const tbody = document.querySelector('tbody')
const response = await fetch('http://localhost:3000/categories')
const data = await response.json()
console.log('data', data)
/*
description: "All Clothing for men"
id: "19d4"
isActive: true
name: "Men's Clothing"
*/
for (const category of data) {
tbody.innerHTML += `
<tr>
<td>${category.id}</td>
<td>${category.name}</td>
<td>${category.description}</td>
<td>${category.isActive}</td>
<td></td>
</tr>
`
}
}
getCategories()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment