JSFiddle - React, Tailwind, and code Playground

HTML

<script src="http://code.appendto.com/plugins/jquery-mockjax/jquery.mockjax.js"></script>
<html>
<body>
    <div id='my-output'>    
        Hello, World.
    </div>
</body>
</html>

JavaScript

runMyTest();

function runMyTest() {
 
    $.mockjax({
        url: '/my/endpoint',
        type: 'POST',
        responseTime: 200,
        //status: 9999,
        response: function (settings) {
            this.status = 9999;
                if (settings.data.user === 'test' && settings.data.password === 'test') {
                    this.status = 200;
                    this.responseText = {
                        message: 'logged in.'
                    }
                } else {
                    this.status = 404;
                    this.responseText = {
                        message: 'invalid'
                    }
                }
         }
    })
    
    // this one matches because the mockHandler.data is undefined
    $.ajax({
        url: '/my/endpoint',
        type: 'POST',
        data: { user: 'test2', password: 'test' },
        contentType: 'application/json; charset=utf-8',
        dataType: 'json',
        complete: function (response) { console.log(response); }
        
    });   

}