0
在我链接到另一个线程之前,我已经检查了此论坛上有关此问题的其他答案。我的JSON格式正确,JSON不包含HMTL。我知道'钥匙'是单引号,但双引号不能解决问题。该请求将发送到本地主机。从React发布到Flask:Uncaught(在promise中)SyntaxError:意外的token <在JSON中
下面是来自反应文件中的POST:
fetch(URL + '/api/' + this.props.choice, {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
body:JSON.stringify({'Key': this.state.value})
})
这里的从烧瓶文件中的GET:
@app.route('/api/Junk', methods = ['GET', 'POST'])
def junk():
junk_request = request.get_json(force = True)
print junk_request
junk_date_var = junk_request["Key"]
从铬调试错误消息:从
fetch uncaught (in promise) syntaxerror: unexpected token < in JSON at position 0
输出终端:
{u'Key': u'Select'}
你只是说它是一个Unicode字符。奇怪的是,这个EXACT代码几天前还在工作。这让我认为某些许可已关闭,或者Node出现问题。