javascript - 需要帮助使用 Vuex 使用 Firebase Rest API 发送 DELETE 请求
问题描述
我正在尝试从 firebase 中删除一些信息,但在使其正常工作时遇到了一些麻烦。
我想要做的是让 deleteRequest 按钮删除从获取链接中提取的数据。
这是按钮和方法
<div class="actions">
<base-button @click="deleteRequest">Delete</base-button>
</div>
async deleteRequest() {
await this.$store.dispatch('requests/deleteRequest', {
email: this.email,
message: this.message,
artistId: this.$route.params.id,
});
async deleteRequest(context, payload) {
const removeRequest = {
userEmail: payload.email,
message: payload.message
};
const response = await fetch(`https://find-artist-d3495-default-rtdb.firebaseio.com/requests/${payload.artistId}.json`, {
method: 'DELETE',
body: JSON.stringify(removeRequest)
});
const responseData = response.json();
if (!response.ok) {
const error = new Error(responseData.message || 'Failed to send request.');
throw error;
}
context.commit('deleteRequests', removeRequest);
},
解决方案
推荐阅读
- excel - 当我激活一个复选框并且连接的单元格的值变为 True 或“WAHR”时,更改特定单元格范围的内部颜色
- python - pd.set_option 不会改变数据框显示的内容
- api - 使用本地策略实现 nuxtjs/auth 的问题
- google-bigquery - BigQuery - 如何根据数组元素对查询结果进行排序
- node.js - 在我的数据库中更改实体后,如何在 typeorm 中更新我的实体?
- python - 如何将密码添加到使用 pandas 数据框创建的 csv/excel
- android - 我需要一个命令从 selenium 的命令行打开 android 上的 chrome
- flutter - 编写涉及选择下拉菜单项的颤振测试
- sql - 如何从sql查询中json列中的json子字符串中检索信息
- javascript - 您可以在无需登录 Auth0 的情况下使用通用 MFA 进行嵌入式注册吗?