Editor Delete Cannot read property 'replace' of undefined

Editor Delete Cannot read property 'replace' of undefined

1ticket1ticket Posts: 11Questions: 8Answers: 1

When I select a row to delete it, no requests are made and I get this error:

let credentialsFunc = (method, url, data, success, error) => {
        d = JSON.parse(JSON.stringify(data));``
        let { cust_account_id, username, password, account_type_id} = d.data[Object.keys(d.data)[0]];

        data = JSON.stringify({
            username,
            password,
            account_type_id: parseInt(account_type_id)
        });

        actions = {
            "create": "POST",
            "edit": "PUT",
            "remove": "DELETE"
        }

        method = actions[d.action]

        if(method === "POST"){
            url = `${_config.apis.dti1ticketapps.credentials1ticket}/9147`
        } else {
            url = `${_config.apis.dti1ticketapps.credentials1ticket}/9147/${cust_account_id}`
        }

        $.ajax( {
            type: method,
            url:  url,
            ...(method !== 'DELETE' && {data}),
            headers: {
                'x-api-key': _config.apis.dti1ticketapps.token,
                    },
            dataType: "json",
            contentType:"application/json; charset=utf-8",
            success: function (json) {
                success( json );
            },
            error: function (xhr, err, thrown) {
                error( xhr, err, thrown );
            }
        } );
    };

    Window.systemsManager.editor = editor = new $.fn.dataTable.Editor({
        dom: "Bfrtip",
        idSrc:  'cust_account_id',
        ajax: {
            create: credentialsFunc,
            edit: credentialsFunc,
            delete: credentialsFunc,
        },

Answers

  • 1ticket1ticket Posts: 11Questions: 8Answers: 1

    sorry nevermind. figured it out

  • allanallan Posts: 64,773Questions: 1Answers: 10,724 Site admin

    What was the issue in the end? Was the id source a number?

    Allan

This discussion has been closed.