Encountering the following error message:
Uncaught (in promise) SyntaxError: Unexpected end of input
when attempting to post references to my specific express server. Can anyone here offer assistance?
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)
})
}
The issue is occurring at this point: .then(res => res.json())
NOTE: The values for firstName, lastName, username, and password are derived from input fields.