Reactjs 此错误阻止我向数据库提交问题
一段时间以来,我一直在为jeopardy编写一个帮助复习考试的程序。我已经走得很远了,但我似乎无法解决我一直遇到的这个错误 我能收集到的是,它是从这里的这些块中产生的Reactjs 此错误阻止我向数据库提交问题,reactjs,Reactjs,一段时间以来,我一直在为jeopardy编写一个帮助复习考试的程序。我已经走得很远了,但我似乎无法解决我一直遇到的这个错误 我能收集到的是,它是从这里的这些块中产生的 fetch(`${config.API_ENDPOINT}/questions`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: newQuestion })
fetch(`${config.API_ENDPOINT}/questions`,
{
method: 'POST',
headers: { 'content-type': 'application/json' },
body: newQuestion
})
.then(res => {
if (!res.ok)
return res.json().then(e => Promise.reject(e))
return res.json()
})
.then(response => this.context.addQuestion(response))
.then(
console.log(newQuestion),
this.props.history.push('/')
)
.catch(error => {
alert(error.message)
})
}
getBoardsId(boards_id) {
console.log(boards_id)
return fetch(`${config.API_ENDPOINT}/boards`, {
headers: {
'authorization': `basic ${TokenService.getAuthToken()}`
},
})
.then(res =>
(!res.ok)
? res.json().then(e => Promise.reject(e))
: res.json()
)
}
您的
newQuestion
变量看起来怎么样?