Fix adding to collection to change value of is_public first try

This commit is contained in:
Sean Morley
2024-09-10 09:30:09 -04:00
parent f7c440c364
commit 4c858ab8b5
4 changed files with 23 additions and 76 deletions

View File

@@ -88,16 +88,18 @@
return;
} else {
let adventure = event.detail;
let formData = new FormData();
formData.append('collection_id', collection.id.toString());
let res = await fetch(`/adventures/${adventure.id}?/addToCollection`, {
method: 'POST',
body: formData // Remove the Content-Type header
let res = await fetch(`/api/adventures/${adventure.id}/`, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ collection: collection.id.toString() })
});
if (res.ok) {
console.log('Adventure added to collection');
adventure = await res.json();
adventures = [...adventures, adventure];
} else {
console.log('Error adding adventure to collection');