在用fetch向本地mock接口请求数据失败
这是报错信息
这是post请求的代码
function post(url, data) {
console.log(url, data);
return fetch(url, {
method: "POST",
headers: headers,
body: data
}).then(response => {
return handleResponse(url, response);
}).catch(error => {
console.error(`Request failed. Url = ${url}. Message = ${error}`);
return Promise.reject({ error: { message: "Request failed." } })
})
}
请问怎么才能请求到数据啊,这个接口没问题 直接在导航栏输入http://localhost:3000/user/User.json也能访问到
你发过去的是对象,当然不行,转成字符串