我在 React 中创建了 chrome 扩展。在请求网址删除
期间,我收到错误:错误:DELETE chrome-extension://ldkflkflkfklfkfksfk/[object%20Object] net::ERR_FILE_NOT_FOUND
我之前尝试过使用 Get
方法。这个方法有效。另外 token、url 都很好。
在响应 header
的选项卡network
中,我显示了临时 header
delete = (id) => {
const url = `https://applic.com/api/v1/todos/${id}?expand=createdBy`;
const token = '12345';
axios.delete({
url: url,
headers: { 'Authorization' : `Bearer ${token}` }
}).then(function(response) {
console.log(`Deleted: ${id}` );
}).catch(function (error) {
console.log(`error: ${id}`);
});
const filter = this.state.items.filter(item=> item.id !== id);
this.setState({
items: filter,
isOpen: false
});
}
最佳答案
axios.delete
的语法是 axios.delete(url[, config])
API 调用应该是:
axios.delete(
url,
{
headers: { 'Authorization' : `Bearer ${token}`
}
})
关于javascript - React 中的 axios.delete : `Error:DELETE chrome-extension://...` ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56806358/