Uncaught (in promise) TypeError: h.json is not a function in React.js

时间:2021-06-16 12:59:54

标签: javascript json reactjs express

我在反应中有上述错误。以下代码导致错误。这发生在按下联系表单中的提交按钮之后。错在哪里?

ContactForm.js

const ContactForm = () => {
  const [status, setStatus] = useState("Submit");
  const handleSubmit = async (e) => {
    e.preventDefault();
    setStatus("Sending...");
    const { name, email, subject, business, datetime, launch, message } = e.target.elements;
    let details = {
      name: name.value,
      email: email.value,
      subject: subject.value,
      business: business.value,
      datetime: datetime.value,
      launch: launch.value,
      message: message.value,
    };
    let response = await("https://delightart.co/send", {
      method: "POST",
      headers: {
        "Content-Type": "application/json;charset=utf-8",
      },
      body: JSON.stringify(details),
    });
    setStatus("Submit");
    let result = await response.json();
    alert(result.status);
  };

0 个答案:

没有答案