Skip to content

Commit 9d08b95

Browse files
fix: Update test.html to use correct production API endpoints
- Changed API_URL from /api/public/sheets/series to /api/public/series - Updated test to use /data endpoint for fetching series data - Testing with real series ID (wb/NE.EXP.GNFS.ZS/USA) instead of non-existent FRED-GDP - Updated response parsing to match new API format {seriesId, data: [{date, value}]} - Improved error handling for 404 responses
1 parent 2fc40dc commit 9d08b95

1 file changed

Lines changed: 30 additions & 11 deletions

File tree

test.html

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ <h2>📊 Overall Status</h2>
126126

127127
<script>
128128
const BASE_URL = 'https://plugins.datasetiq.com';
129-
const API_URL = 'https://www.datasetiq.com/api/public/sheets/series';
129+
const API_URL = 'https://www.datasetiq.com/api/public/series';
130130
let testResults = {};
131131

132132
async function testEndpoint(name, path) {
@@ -164,14 +164,28 @@ <h2>📊 Overall Status</h2>
164164
resultDiv.textContent = 'Testing API without authentication...';
165165

166166
try {
167-
const response = await fetch(`${API_URL}/FRED-GDP?mode=latest`);
167+
// Test with a real series ID from search results
168+
const response = await fetch(`${API_URL}/wb%2FNE.EXP.GNFS.ZS%2FUSA/data?limit=3`);
168169
const status = response.status;
169170

170-
// API requires authentication, so 401/403/404 are expected
171-
if (status === 401 || status === 403 || status === 404) {
172-
testResults['api'] = true;
173-
resultDiv.className = 'result success';
174-
resultDiv.textContent = `✅ API endpoint exists and requires authentication (HTTP ${status})\nThis is expected behavior. Use "Test with API Key" to verify full functionality.`;
171+
// Unauthenticated requests get limited data (100 observations)
172+
if (status === 200) {
173+
const data = await response.json();
174+
if (data.data && Array.isArray(data.data)) {
175+
testResults['api'] = true;
176+
resultDiv.className = 'result success';
177+
resultDiv.textContent = `✅ API endpoint working!\nSeries: ${data.seriesId}\nData points: ${data.data.length}\nLatest: ${JSON.stringify(data.data[data.data.length - 1])}\nHas more: ${data.hasMore}`;
178+
updateOverallStatus();
179+
return;
180+
}
181+
}
182+
183+
// 404 means series not found or wrong endpoint
184+
if (status === 404) {
185+
const errorData = await response.json().catch(() => null);
186+
resultDiv.className = 'result error';
187+
resultDiv.textContent = `❌ HTTP 404: Series not found or incorrect endpoint\nURL: ${response.url}\nError: ${errorData ? JSON.stringify(errorData) : 'Unknown'}`;
188+
testResults['api'] = false;
175189
updateOverallStatus();
176190
return;
177191
}
@@ -211,22 +225,27 @@ <h2>📊 Overall Status</h2>
211225
resultDiv.textContent = 'Testing API with authentication...';
212226

213227
try {
214-
const response = await fetch(`${API_URL}/FRED-GDP?mode=latest`, {
228+
// Test data endpoint with auth (gets 1000 observations limit)
229+
const response = await fetch(`${API_URL}/wb%2FNE.EXP.GNFS.ZS%2FUSA/data?limit=5`, {
215230
headers: { 'Authorization': `Bearer ${key}` }
216231
});
217232
if (!response.ok) {
233+
const errorData = await response.json().catch(() => null);
218234
resultDiv.className = 'result error';
219-
resultDiv.textContent = `❌ HTTP ${response.status}: ${response.statusText}`;
235+
resultDiv.textContent = `❌ HTTP ${response.status}: ${response.statusText}\n${errorData ? JSON.stringify(errorData, null, 2) : ''}`;
220236
return;
221237
}
222238
const data = await response.json();
223239

224240
if (data.error) {
225241
resultDiv.className = 'result error';
226242
resultDiv.textContent = `❌ ${data.error.message}\nCode: ${data.error.code}`;
227-
} else {
243+
} else if (data.data && Array.isArray(data.data)) {
228244
resultDiv.className = 'result success';
229-
resultDiv.textContent = `✅ Authenticated successfully!\nLatest GDP: ${data.scalar}\nFull response:\n${JSON.stringify(data, null, 2)}`;
245+
resultDiv.textContent = `✅ Authenticated successfully!\nSeries: ${data.seriesId}\nData points: ${data.data.length}\nSample data:\n${JSON.stringify(data.data.slice(0, 3), null, 2)}\nHas more: ${data.hasMore}`;
246+
} else {
247+
resultDiv.className = 'result error';
248+
resultDiv.textContent = `❌ Unexpected response format:\n${JSON.stringify(data, null, 2)}`;
230249
}
231250
} catch (error) {
232251
resultDiv.className = 'result error';

0 commit comments

Comments
 (0)