api call cleanup
This commit is contained in:
+17
-1
@@ -1,4 +1,4 @@
|
||||
const API_BASE = 'http://192.168.178.41:3000'; // Backend URL
|
||||
const API_BASE = 'http://192.168.178.41:3000';
|
||||
|
||||
export async function fetchCards() {
|
||||
const response = await fetch(`${API_BASE}/exportCards`);
|
||||
@@ -11,4 +11,20 @@ export async function fetchCardImage(cardId) {
|
||||
if (!response.ok) throw new Error('Failed to fetch card image');
|
||||
const data = await response.json();
|
||||
return data.image;
|
||||
}
|
||||
|
||||
export async function updateCardAmount(cardId, setId, rarityId, amount) {
|
||||
const response = await fetch(`${API_BASE}/collection/amount`, {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
card_id: cardId,
|
||||
set_id: setId,
|
||||
rarity_id: rarityId,
|
||||
amount_owned: amount
|
||||
})
|
||||
});
|
||||
|
||||
if (!response.ok) throw new Error('Failed to update amount');
|
||||
return await response.json();
|
||||
}
|
||||
Reference in New Issue
Block a user