Javascript 表单提交错误声明。然后不是错误

Javascript 表单提交错误声明。然后不是错误,javascript,Javascript,当我在客户端提交表单时,我得到了错误信息 (index):83 Uncaught TypeError: {(intermediate value)(intermediate value)(intermediate value)}.then is not a function at HTMLFormElement.Submit 它指向以下代码行: .then((res) => res.json()) 在这个代码块中: function Submit(e) { e.pr

当我在客户端提交表单时,我得到了错误信息

(index):83 Uncaught TypeError: {(intermediate value)(intermediate value)(intermediate value)}.then is not a function
    at HTMLFormElement.Submit
它指向以下代码行:

.then((res) => res.json())
在这个代码块中:

function Submit(e) {
      e.preventDefault();

      let body = document.getElementById('search').nodeValue;

      fetch ("/:url + theURL"), {
        method: 'GET',
        headers: {
          'Accept': 'application/json, text/plain, */*',
          'Content-type': 'applcation.json'
      },
      body:JSON.stringify({search:search})
    }
    .then((res) => res.json())
    .then((data) => console.log(data))
  }

有没有关于如何避免这个问题的建议?

我认为您有语法错误。应该将右括号移到fetch函数的所有参数之后

fetch ("/:url + theURL", {
    method: 'GET',
    headers: {
      'Accept': 'application/json, text/plain, */*',
      'Content-type': 'applcation.json'
  },
  body:JSON.stringify({search:search})
})
.then((res) => res.json())
.then((data) => console.log(data))

小提示:数一数括号和大括号,开口的数量必须等于闭包的数量。并使用一个干净的缩进。。。