javascript - JavaScript + 火力基地。如何使用 fetch for farebase 实现请求,以便删除 farebase 中的项目
问题描述
API_BASE = `https://dims.firebaseio.com/`;
editResource = async (url, body) => {
const res = await fetch(`${this.API_BASE}${url}`, {
method: 'PUT',
body: JSON.stringify(body),
});
return await res.json();
}
editMember = async (memberId, body) => {
return await this.editResource(`/UserProfile/${memberId}`, body);
}
delResource = async (url) => {
await fetch(`${this.API_BASE}${url}`, {
method: 'DELETE',
})
.then(response => response.json());
};
delMember = async (memberId) => {
return await this.delResource(`/UserProfile/${memberId}`);
};
结果: 选项:405(不允许方法)访问从源“ http://localhost:3000 ”获取的“ https://dims.firebaseio.com//UserProfile/-M0r1o70-G2JMzQYXbm1 ”已被 CORS 策略阻止:对预检请求的响应未通过访问控制检查:它没有 HTTP ok 状态。
解决方案
推荐阅读
- python - I am trying to resume training from a certain checkpoint (Tensorflow) because I'm using Colab and 12 hours aren't enough
- python - 了解 SQLAlchemy ForeignKey 关系查询结果
- flutter - Flutter灵活文本在列中溢出
- python - ImportError:无法从“plotly.express”导入名称“Constant”
- bash - 从 AWS S3 下载库存文件
- flutter - 如何使标签栏中的文本显示在同一行?
- node.js - Async/await 通过错误处理执行多个功能
- java - 如何使对话框片段的背景不可见?
- mysql - 如何从准备好的语句创建视图或表(选择查询)
- java - 无法创建生产者在 ActiveMQ 上发送消息