JavaScript Promises: an Introduction https://developers.google.com/web/fundamentals/primers/promises

Fetching data

fetch(url) // Call the fetch function passing the url of the API as a parameter
.then(function() {
    // Your code for handling the data you get from the API
})
.catch(function() {
    // This is where you run code if the server returns any errors
});
// https://randomuser.me/api/?results=10

How to Use the JavaScript Fetch API to Get Data https://scotch.io/tutorials/how-to-use-the-javascript-fetch-api-to-get-data

function saveRow(){
      let data = {
        id: txtId.value,
        name: txtName.value
      }
      console.log(data);
      let fetchData = {
        method: 'POST',
        body: data
      }
      
      fetch('/prefix', fetchData)
        .then ((resp) => {
          console.log(resp);
          resp.json();
        })
        .then( function(data){

            const oldId = parseInt(txtId.value);
            const newId = parseInt(data.id);
            let row = `<tr>
                          <td id="row-${data.id}">${data.name}</td>
                          <td>
                            <button class="row-edit-button" title="Edit" data-toggle="tooltip" data-placement="top" onclick="editRow(${data.id})">
                                  <i class="fa fa-edit size-18 text-yellow"></i>
                              </button>
                          </td>
                        </tr>`;
              if (oldId === 0){ 
                tbl.append(row);
              } else {
                const rowId = `row-${data.id}`;
                document.getElementById(rowId).innerHTML = data.name;
              }
              cancelEdit();
        })
        .catch (function(error){
            console.log(error);
        });

        return false;
      }