콘솔메세지추가
This commit is contained in:
@@ -5,10 +5,12 @@ const API_Base_URL = '/api/markers';
|
||||
|
||||
export const apiService = {
|
||||
getHotspots: async (): Promise<WiFiHotspot[]> => {
|
||||
console.log(`[API Call] GET ${API_Base_URL}`);
|
||||
try {
|
||||
const response = await fetch(API_Base_URL);
|
||||
if (!response.ok) throw new Error('Failed to fetch markers');
|
||||
const data = await response.json();
|
||||
console.log(`[API Response] Received ${data.length} hotspots`, data);
|
||||
return data;
|
||||
} catch (e) {
|
||||
console.error("Failed to load hotspots from API", e);
|
||||
@@ -17,6 +19,7 @@ export const apiService = {
|
||||
},
|
||||
|
||||
saveHotspot: async (hotspot: WiFiHotspot): Promise<void> => {
|
||||
console.log(`[API Call] POST ${API_Base_URL}`, hotspot);
|
||||
try {
|
||||
const response = await fetch(API_Base_URL, {
|
||||
method: 'POST',
|
||||
@@ -26,6 +29,8 @@ export const apiService = {
|
||||
body: JSON.stringify(hotspot),
|
||||
});
|
||||
if (!response.ok) throw new Error('Failed to save marker');
|
||||
const data = await response.json();
|
||||
console.log(`[API Response] Save success:`, data);
|
||||
// Trigger a storage event to refresh UI if needed (keeping compatibility)
|
||||
window.dispatchEvent(new Event('storage_updated'));
|
||||
} catch (e) {
|
||||
@@ -34,11 +39,15 @@ export const apiService = {
|
||||
},
|
||||
|
||||
deleteHotspot: async (id: string): Promise<void> => {
|
||||
const url = `${API_Base_URL}/${id}`;
|
||||
console.log(`[API Call] DELETE ${url}`);
|
||||
try {
|
||||
const response = await fetch(`${API_Base_URL}/${id}`, {
|
||||
const response = await fetch(url, {
|
||||
method: 'DELETE',
|
||||
});
|
||||
if (!response.ok) throw new Error('Failed to delete marker');
|
||||
const data = await response.json();
|
||||
console.log(`[API Response] Delete success:`, data);
|
||||
window.dispatchEvent(new Event('storage_updated'));
|
||||
} catch (e) {
|
||||
console.error("Failed to delete hotspot", e);
|
||||
|
||||
Reference in New Issue
Block a user