How do I use a variable to make the following code reusable? Can I embed a variable in a template literal variable?
I am getting an object from the endpoint and I want to access object.CategoryName
here is my current code
export default function getCategoryAll(url, appendId, dataTitle, dataBody) {
    return $.ajax({
        url: url,
        type: 'GET',
        data: {
        },
        success: function (data) {
            console.log(data);
            // work here
            data.map((data) => {
                $(`#${appendId}`).append(`
                <div class="items-list-container">
                    <div class="items-list-content">
                    <div class="h5 items-list-content-title">${data + "." + dataTitle}}</div>
                    <div class="items-list-content-body d-flex"></div>
                    <button class="items-list-update-button badge btn btn-outline-success">Update</button></div>
                </div>`)
                return data
            })
        },
        error: function (jqXHR, textStatus, errorThrown) {
            // Empty most of the time...
            $('#setting-category-list').append("<h4>Error!</h4>")
        }
    });
}
getCategoryAll("/getCategoryAll", "setting-category-list", "CategoryName")
