From 13b563e35e7a72680df0d7f3f5990e257d7aafae Mon Sep 17 00:00:00 2001 From: Beilin-b Date: Sun, 14 Jun 2026 08:22:59 -0700 Subject: [PATCH] fixing SendGeneralReport --- app/utils/api.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/app/utils/api.js b/app/utils/api.js index 083137e..54ca487 100644 --- a/app/utils/api.js +++ b/app/utils/api.js @@ -449,6 +449,10 @@ // }); // } + + + + import AuthService from '../services/AuthService'; const API_BASE = process.env.NEXT_PUBLIC_API_URL || 'https://45.93.137.91.nip.io/api'; @@ -475,7 +479,13 @@ async function apiFetch(endpoint, options = {}) { headers['Content-Type'] = 'application/json'; } - const res = await fetch(`${API_BASE}${endpoint}`, { + const url = `${API_BASE}${endpoint}`; + + console.log('API Request:', url); + console.log('API Method:', options.method || 'GET'); + console.log('API Body:', hasBody ? options.body : null); + + const res = await fetch(url, { ...options, headers, body: @@ -484,8 +494,12 @@ async function apiFetch(endpoint, options = {}) { : options.body, }); + console.log('API Response Status:', res.status); + console.log('API Response OK:', res.ok); + if (!res.ok && res.status !== 206) { const text = await res.text().catch(() => ''); + console.error('API Error Response:', text || res.statusText); throw new Error(`API ${res.status}: ${text || res.statusText}`); } @@ -1029,7 +1043,7 @@ export async function filterRentProperties(params = {}) { // ─── Reports ─── export async function submitReport(subject, body) { - return apiFetch('/Reports', { + return apiFetch('/Reports/SendGeneralReport', { method: 'POST', body: { subject, body }, });