const textClassForm = document.querySelector('.text-class-form'); const classifyText = async (text) => { const inferResponse = await fetch(`predict/predict?query=${text}`); const inferJson = await inferResponse.json(); console.log(inferJson.label) return inferJson.label; }; textClassForm.addEventListener('submit', async (event) => { event.preventDefault(); const textClassInput = document.getElementById('text-class-input'); const textClassParagraph = document.querySelector('.text-class-output'); try { textClassParagraph.textContent = await classifyText(textClassInput.value); } catch (err) { console.error(err); } });