Javascript 接收错误意外令牌<;在JSON中的位置0;这是后端还是前端问题?

Javascript 接收错误意外令牌<;在JSON中的位置0;这是后端还是前端问题?,javascript,reactjs,asynchronous,Javascript,Reactjs,Asynchronous,我目前有一个补丁方法: export const patchEvent=(eventToUpdate)=>dispatch=>{ 取回(`http://localhost:3000/events/${eventToUpdate.id}/`{ 方法:“补丁”, 标题:{ “接受”:“应用程序/json”, “内容类型”:“应用程序/json” }, 正文:JSON.stringify({ 已雇用工人:eventToUpdate.workers\u已雇用 }) }) .then(res=>res.j

我目前有一个补丁方法:

export const patchEvent=(eventToUpdate)=>dispatch=>{
取回(`http://localhost:3000/events/${eventToUpdate.id}/`{
方法:“补丁”,
标题:{
“接受”:“应用程序/json”,
“内容类型”:“应用程序/json”
},
正文:JSON.stringify({
已雇用工人:eventToUpdate.workers\u已雇用
})
})
.then(res=>res.json())
。然后(数据=>{
派遣({
类型:PATCH_事件,
有效载荷:eventToUpdate.workers\u已雇用
})
})
}
从React事件接收数据的:

const addWorker=()=>{
const viewedEvent=props.rawEvents.find(事件=>{
return event.name==props.event.title
})
viewedEvent.workers\u hired=5
道具修补事件(viewedEvent)
}
其中,props.patchEvent是我的Redux操作,显示在第一个代码段中

启动此操作时,我收到一个404错误“位置0处JSON中的意外标记<”


现在,我明白了这与fetch响应的JSON格式不正确有关,但我一辈子都搞不清楚代码中的格式哪里出了问题。任何帮助都将不胜感激

错误404表示找不到您请求的url。检查您是否获取了正确的url。

您的后端返回HTML 404错误页面,而不是JSON格式的响应。