larxius commited on
Commit
93ea066
·
verified ·
1 Parent(s): 970d624

Update frontend/src/pages/ScanResults.jsx

Browse files
Files changed (1) hide show
  1. frontend/src/pages/ScanResults.jsx +12 -7
frontend/src/pages/ScanResults.jsx CHANGED
@@ -99,7 +99,7 @@ export const ScanResults = () => {
99
 
100
  const loadScanHistory = async () => {
101
  try {
102
- const res = await fetch('/api/scans/history', {
103
  headers: { 'Authorization': `Bearer ${token}` }
104
  });
105
  if (res.ok) {
@@ -138,12 +138,14 @@ export const ScanResults = () => {
138
  const fetchScanData = async (id, page = 1) => {
139
  setLoading(true);
140
  try {
141
- const scanRes = await fetch(`/api/scans/${id}`, {
142
- headers: { 'Authorization': `Bearer ${token}` }
143
- });
144
- const vulnsRes = await fetch(`/api/scans/${id}/vulnerabilities?page=${page}&limit=50`, {
145
- headers: { 'Authorization': `Bearer ${token}` }
146
- });
 
 
147
 
148
  if (scanRes.ok && vulnsRes.ok) {
149
  const scanData = await scanRes.json();
@@ -175,9 +177,12 @@ export const ScanResults = () => {
175
 
176
  // Reset selected vuln when changing scans
177
  setSelectedVuln(null);
 
 
178
  }
179
  } catch (err) {
180
  console.error("Error fetching scan details", err);
 
181
  } finally {
182
  setLoading(false);
183
  }
 
99
 
100
  const loadScanHistory = async () => {
101
  try {
102
+ const res = await fetch('/api/scans/history?limit=100', {
103
  headers: { 'Authorization': `Bearer ${token}` }
104
  });
105
  if (res.ok) {
 
138
  const fetchScanData = async (id, page = 1) => {
139
  setLoading(true);
140
  try {
141
+ const [scanRes, vulnsRes] = await Promise.all([
142
+ fetch(`/api/scans/${id}`, {
143
+ headers: { 'Authorization': `Bearer ${token}` }
144
+ }),
145
+ fetch(`/api/scans/${id}/vulnerabilities?page=${page}&limit=50`, {
146
+ headers: { 'Authorization': `Bearer ${token}` }
147
+ })
148
+ ]);
149
 
150
  if (scanRes.ok && vulnsRes.ok) {
151
  const scanData = await scanRes.json();
 
177
 
178
  // Reset selected vuln when changing scans
179
  setSelectedVuln(null);
180
+ } else {
181
+ setError("Failed to fetch scan details.");
182
  }
183
  } catch (err) {
184
  console.error("Error fetching scan details", err);
185
+ setError("Failed to connect to scanner service.");
186
  } finally {
187
  setLoading(false);
188
  }