CRUD Java web with JS, syntax error while updating

0

When adding the Update feature, a syntax error appears in the console, I know what the problem is however I do not know how to solve it.

view

  template(listaFornecedores) {
        return '<table border='1px'>
        <thead>
            <tr>
                <th>Nome</th>
                <th>CNPJ</th> 
                <th>Email</th>
            <tr>
         </thead>
         <tbody>
            ${listaFornecedores.map(fornecedor =>
                '<tr>
                    <td>${fornecedor.nome}</td>
                    <td>${fornecedor.cnpj}</td>
                    <td>${fornecedor.email}</td>
                    <td><button onclick="controller.remover(event,${fornecedor.id})">DELETAR</button></td>
                    <td><button onclick="controller.atualizarFornecedor(event,${fornecedor})">ATUALIZAR</button></td>


                 </tr>
                ').join('')}
         </tbody>
    </table>';
}

Explanation: Focusing on the problem, the event that will be triggered must receive all attributes that were typed in the form so that it updates itself, however it accuses of  a syntax error for not being able to receive an object

Controller

atualizarFornecedor(event,fornecedor){event.preventDefault();console.log(fornecedor);letnome=document.querySelector("#txtnome").value;
    let cnpj = document.querySelector("#txtcnpj").value;
    let email = document.querySelector("#txtemail").value;
    //fornecedor = new Fornecedor(nome, cnpj, email);
    fornecedor.nome = nome;
    fornecedor.cnpj = cnpj;
    fornecedor.email = email;

    const self = this;

    this._service.atualizaFornecedor(fornecedor,
            function () {
                self.limparCamposFormulario();
                self.carregaFornecedor();
            },
            function (msg) {
                console.log(msg);
            }
    );
}

Explanation 2 In this form we receive the new data, the idea would be to modify supplier  by the new values received, however I can not pass an object.

If you need to post part of the code, just put it in the comments

    
asked by anonymous 06.07.2018 / 18:44

0 answers