JSFiddle - React, Tailwind, and code Playground

JavaScript

$(window).unload(function () {
    $.ajax({
        url: "/echo/json/",
        async: false,
        timeout: 1000,
        global: false,
        type: "POST",
        contentType: "application/json; charset=UTF-8",
        dataType: "json",
        data: {},
        error: function (jqXhr, textStatus, errorThrown) {
            alert(errorThrown);
        }
    });
})

$(window).trigger('unload');