async function renderList( element ) {

  /**
   * all item datasets
   * @type {Object[]}
   */
  const items = await fetch( 'http://localhost:8080/api/v1/items', { method: 'GET' } ).then( result => result.json() );

  // set content of <body>
  element.innerHTML = `
    <div class="container-fluid">
      <h1>MyStuff Frontend <span class="badge badge-warning">JavaScript</span></h1>
      <table class="table table-hover">
        <thead class="thead-light">
          <tr>
            <th scope="col">#</th>
            <th scope="col">Name</th>
            <th scope="col">Location</th>
            <th scope="col">Amount</th>
            <th scope="col">Description</th>
            <th scope="col"></th>
            <th scope="col"></th>
            <th scope="col"></th>
          </tr>
        </thead>
        <tbody>
        </tbody>
      </table>
      <button type="button" class="btn btn-success btn-sm">Create</button>
    </div>
  `;

  // append table row for each loaded item dataset
  items.forEach( function ( item ) {
    const entry = `
<tr>
  <th scope="row">${item.id}</th>
  <td>${item.name}</td>
  <td>${item.location}</td>
  <td>${item.amount}</td>
  <td>${item.description || '-'}</td>
  <td><button type="button" class="btn btn-primary btn-sm" data-id="${item.id}" onclick="renderForm(item.id)">Read</button></td>
  <td><button type="button" class="btn btn-warning btn-sm" data-id="${item.id}">Update</button></td>
  <td><button type="button" class="btn btn-danger btn-sm" data-id="${item.id}">Delete</button></td>
</tr>
    `;
    document.querySelector( 'tbody' ).innerHTML += entry;
  } );

  // set click event for 'Create' button => render form for create new item
  document.querySelector( '.btn-success' ).addEventListener( 'click', renderForm );

  // set click event for all 'Read' buttons => show item as readonly form
  document.querySelectorAll( '.btn-primary' ).forEach( button => {
    button.addEventListener( 'click', async () => {
      const id = button.dataset.id;
      const item = items.find( item => item.id == id );
      await renderForm( item, true );
    } );
  } );

  // set click event for all 'Update' buttons => render form for update of item
  document.querySelectorAll( '.btn-warning' ).forEach( button => {
    button.addEventListener( 'click', async () => {
      const id = button.dataset.id;
      const item = items.find( item => item.id == id );
      await renderForm( item );
    } );
  } );

  // set click event for all 'Delete' buttons => delete item
  document.querySelectorAll( '.btn-danger' ).forEach( button => {
    button.addEventListener( 'click', async () => {
      await fetch( 'http://localhost:8080/api/v1/item/' + button.dataset.id, { method: 'DELETE' } );
      await renderList();
    } );
  } );

}
/**
 * renders a list of all items inside <body>
 * @returns {Promise<void>}
 */
renders a list of all items inside 
@returns {Promise}
renders a list of all items inside @returns { Promise }
async function renderList( element ) {
  const items = await fetch( 'http://localhost:8080/api/v1/items', { method: 'GET' } ).then( result => result.json() );
  element.innerHTML = `
    <div class="container-fluid">
      <h1>MyStuff Frontend <span class="badge badge-warning">JavaScript</span></h1>
      <table class="table table-hover">
        <thead class="thead-light">
          <tr>
            <th scope="col">#</th>
            <th scope="col">Name</th>
            <th scope="col">Location</th>
            <th scope="col">Amount</th>
            <th scope="col">Description</th>
            <th scope="col"></th>
            <th scope="col"></th>
            <th scope="col"></th>
          </tr>
        </thead>
        <tbody>
        </tbody>
      </table>
      <button type="button" class="btn btn-success btn-sm">Create</button>
    </div>
  `;
  items.forEach( function ( item ) {
    const entry = `
<tr>
  <th scope="row">${item.id}</th>
  <td>${item.name}</td>
  <td>${item.location}</td>
  <td>${item.amount}</td>
  <td>${item.description || '-'}</td>
  <td><button type="button" class="btn btn-primary btn-sm" data-id="${item.id}" onclick="renderForm(item.id)">Read</button></td>
  <td><button type="button" class="btn btn-warning btn-sm" data-id="${item.id}">Update</button></td>
  <td><button type="button" class="btn btn-danger btn-sm" data-id="${item.id}">Delete</button></td>
</tr>
    `;
    document.querySelector( 'tbody' ).innerHTML += entry;
  } );
  document.querySelector( '.btn-success' ).addEventListener( 'click', renderForm );
  document.querySelectorAll( '.btn-primary' ).forEach( button => {
    button.addEventListener( 'click', async () => {
      const id = button.dataset.id;
      const item = items.find( item => item.id == id );
      await renderForm( item, true );
    } );
  } );
  document.querySelectorAll( '.btn-warning' ).forEach( button => {
    button.addEventListener( 'click', async () => {
      const id = button.dataset.id;
      const item = items.find( item => item.id == id );
      await renderForm( item );
    } );
  } );
  document.querySelectorAll( '.btn-danger' ).forEach( button => {
    button.addEventListener( 'click', async () => {
      await fetch( 'http://localhost:8080/api/v1/item/' + button.dataset.id, { method: 'DELETE' } );
      await renderList();
    } );
  } );
}
async function renderList ( element ) { const items = await fetch ( 'http://localhost:8080/api/v1/items' , { method : 'GET' } ) . then ( result => result . json ( ) ) ; element . innerHTML = ` ` ; items . forEach ( function ( item ) { const entry = ` ${ item . id } ${ item . name } ${ item . location } ${ item . amount } ${ item . description || '-' } ${ item . id } ${ item . id } ${ item . id } ` ; document . querySelector ( 'tbody' ) . innerHTML += entry ; } ) ; document . querySelector ( '.btn-success' ) . addEventListener ( 'click' , renderForm ) ; document . querySelectorAll ( '.btn-primary' ) . forEach ( button => { button . addEventListener ( 'click' , async ( ) => { const id = button . dataset . id ; const item = items . find ( item => item . id == id ) ; await renderForm ( item , true ) ; } ) ; } ) ; document . querySelectorAll ( '.btn-warning' ) . forEach ( button => { button . addEventListener ( 'click' , async ( ) => { const id = button . dataset . id ; const item = items . find ( item => item . id == id ) ; await renderForm ( item ) ; } ) ; } ) ; document . querySelectorAll ( '.btn-danger' ) . forEach ( button => { button . addEventListener ( 'click' , async ( ) => { await fetch ( 'http://localhost:8080/api/v1/item/' + button . dataset . id , { method : 'DELETE' } ) ; await renderList ( ) ; } ) ; } ) ; }
renders a list of all items inside <body>
 @returns {Promise<void>}
renders a list of all items inside <body > @returns { Promise<void > }
/**
   * all item datasets
   * @type {Object[]}
   */ // set content of <body> // append table row for each loaded item dataset // set click event for 'Create' button => render form for create new item // set click event for all 'Read' buttons => show item as readonly form // set click event for all 'Update' buttons => render form for update of item // set click event for all 'Delete' buttons => delete item