How to pass javascript array of dictionary to flask

I have an array of dictionaries in javascript that I want to send as payload to a POST request to flask.

However, the array always gets sent empty.

Javascript:

{% for department in departments %}
        var department_id = "{{ department.id }}"
        var cardgroup = $("#cardgroups_{{ department.id }}").val();
        var doorgroup = $("#doorgroups_{{ department.id }}").val();

        data.push({
            department_id: department_id,
            cardgroup_id: cardgroup,
            doorgroup_id: doorgroup
        });
{% endfor %}

$.post("data/save-office/"+office, data={data: data}, function (data) {
        if (data['error']) {
            alert(data['error']);
        }
        else
            if (data['success']) {
                load_table();
            }
        });

python:

@app.post('/data/save-office/<office>')
def save_office(office):
    departments = request.args.getlist('data[]').  # departments = []

I tried to change departments to request.args.getlist('data') but it returned the same thing.

I also tried to use AJAX instead but it was basically the same thing.