【发布时间】:2021-01-09 18:54:08
【问题描述】:
我遇到了错误:Uncaught (in promise) SyntaxError: Unexpected end of input 尝试将 refs 发布到我的专用快递服务器,你们能帮帮我吗?
function create() {
event.preventDefault()
firstName = document.getElementById('firstName').value
lastName = document.getElementById('lastName').value
username = document.getElementById('username').value
password = document.getElementById('password').value
const userInfo = {
firstName: firstName,
lastName: lastName,
username: username,
password: password
}
const config = {
method: "POST",
mode: "no-cors",
body: {userInfo},
headers: {
"Content-Type":"application/json"
}
}
fetch('https://marcelochat.herokuapp.com/create', config)
.then(res => res.json())
.then(resp => {
console.log(resp)
})
}
错误在这里:.then(res => res.json())
注意:firstName、lastName、username 和 password 常量是输入值
【问题讨论】:
标签: javascript express post