Wait datatable load to finish

in javascript i need wait to table load all data content from a string array, my approach is whit “initComplete” but table is not loading.
here is my example code:

<script>

    var myArray = [~alldata~]

    initComplete: buildTable(myArray)



    function buildTable(data){
        var table = document.getElementById('table')

        for (var i = 0; i < data.length; i++){
            var row = `<tr>
                            <td>type</td>
                            <td>${data[i].id}</td>
                            <td>${data[i].de}</td>                                              
                      </tr>`
            table.innerHTML += row


        }
    }

</script>

anyone have a sugestion?

i try the code above