I'm trying to delete some information from firebase and having some trouble getting it to work.
What i'm trying to do is have the deleteRequest button delete the data pulled from the fetch link.
This is the button and method
<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);
},