我在React中创建chrome扩展。在请求网址delete
期间,我收到一个错误:Error: DELETE chrome-extension://ldkflkflkfklfkfksfk/[object%20Object] net::ERR_FILE_NOT_FOUND
我之前尝试过使用Get
方法。此方法有效。令牌,URL也很好。
在network
的标签response headers
中,我有Provisional headers are shown
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
});
}
答案 0 :(得分:1)
axios.delete
的语法为axios.delete(url[, config])
API调用应为:
axios.delete(
url,
{
headers: { 'Authorization' : `Bearer ${token}`
}
})