지도크기오류 수정
This commit is contained in:
@@ -2,16 +2,16 @@
|
||||
import { WiFiHotspot } from '../types';
|
||||
|
||||
const API_Base_URL = '/api/markers';
|
||||
const isDebug = import.meta.env.DEV;
|
||||
|
||||
export const apiService = {
|
||||
getHotspots: async (): Promise<WiFiHotspot[]> => {
|
||||
const fullUrl = `${window.location.origin}${API_Base_URL}`;
|
||||
console.log(`[API Call] GET ${fullUrl} (Origin: ${window.location.origin})`);
|
||||
if (isDebug) console.log(`[API Call] GET ${window.location.origin}${API_Base_URL}`);
|
||||
try {
|
||||
const response = await fetch(API_Base_URL, { cache: 'no-store' }); // 캐시 방지 추가
|
||||
const response = await fetch(API_Base_URL, { cache: 'no-store' });
|
||||
if (!response.ok) throw new Error('Failed to fetch markers');
|
||||
const data = await response.json();
|
||||
console.log(`[API Response] Received ${data.length} hotspots`, data);
|
||||
if (isDebug) console.log(`[API Response] Received ${data.length} hotspots`, data);
|
||||
return data;
|
||||
} catch (e) {
|
||||
console.error("Failed to load hotspots from API", e);
|
||||
@@ -20,7 +20,7 @@ export const apiService = {
|
||||
},
|
||||
|
||||
saveHotspot: async (hotspot: WiFiHotspot): Promise<void> => {
|
||||
console.log(`[API Call] POST ${API_Base_URL}`, hotspot);
|
||||
if (isDebug) console.log(`[API Call] POST ${API_Base_URL}`, hotspot);
|
||||
try {
|
||||
const response = await fetch(API_Base_URL, {
|
||||
method: 'POST',
|
||||
@@ -31,7 +31,7 @@ export const apiService = {
|
||||
});
|
||||
if (!response.ok) throw new Error('Failed to save marker');
|
||||
const data = await response.json();
|
||||
console.log(`[API Response] Save success:`, data);
|
||||
if (isDebug) 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) {
|
||||
@@ -41,14 +41,14 @@ export const apiService = {
|
||||
|
||||
deleteHotspot: async (id: string): Promise<void> => {
|
||||
const url = `${API_Base_URL}/${id}`;
|
||||
console.log(`[API Call] DELETE ${url}`);
|
||||
if (isDebug) console.log(`[API Call] DELETE ${url}`);
|
||||
try {
|
||||
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);
|
||||
if (isDebug) 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