diff --git a/contact.html b/contact.html index 44ac15c..c437d36 100644 --- a/contact.html +++ b/contact.html @@ -169,8 +169,7 @@

お問い合わせ

通常 1〜2 営業日以内にご返信します

- -
+
@@ -205,9 +204,6 @@
- - -
@@ -230,18 +226,27 @@ btn.disabled = true; btn.textContent = '送信中...'; + const data = { + type: document.getElementById('type').value, + name: document.getElementById('name').value, + email: document.getElementById('email').value, + subject: document.getElementById('subject').value, + message: document.getElementById('message').value, + }; + try { - const res = await fetch(form.action, { + const res = await fetch('https://api.soar-enrich.com/api/store/contact', { method: 'POST', - body: new FormData(form), - headers: { Accept: 'application/json' } + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(data), }); if (res.ok) { form.style.display = 'none'; success.style.display = 'block'; } else { - alert('送信に失敗しました。時間をおいて再度お試しください。'); + const err = await res.json().catch(() => ({})); + alert(err.error || '送信に失敗しました。時間をおいて再度お試しください。'); btn.disabled = false; btn.textContent = '送信する'; }