<div id='thread_form' class='modal fade'>
    <form class='modal-dialog modal-dialog-scrollable' method="POST">
        <div class='modal-content'>
            <div class='modal-header'>
                <h5 class='modal-title'>スレッドを作成</h5>
                <button type='button' class='btn-close' data-bs-dismiss='modal'></button>
            </div>
            <div class='modal-body'>
                <div class='mb-3'>
                    <label class='form-label'>スレッドタイトル</label>
                    <input type='text' class='form-control' name='title'/>
                </div>
            </div>
            <div class='modal-footer'>
                <button type='button' class='btn btn-secondary' data-bs-dismiss='modal'>閉じる</button>
                <button type='submit' class='btn btn-primary'>作成</button>
            </div>
        </div>
    </form>
    <script>
        document.querySelector('#thread_form form').onsubmit = function(e){
            e.preventDefault()
            const form = new FormData(this);
            fetch("{{ url("/api/v0/board/" + board._id) }}", {
                method: "POST",
                body: form,
                credentials: "include"
            }).then(res => res.json()).then(res => {
                location.href = "{{ url("/" + board._id + "/") }}" + res._id
            });
        }
    </script>
</div>
