EricSam commited on
Commit
9342591
Β·
verified Β·
1 Parent(s): 1545499

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +14 -4
index.html CHANGED
@@ -293,8 +293,8 @@
293
  });
294
 
295
  // API Configuration
296
- let API_KEY = localStorage.getItem('bingxApiKey') || 'your-actual-api-key'; // Default or stored value
297
- let API_SECRET = localStorage.getItem('bingxApiSecret') || 'your-actual-secret-key'; // Default or stored value
298
  const API_BASE_URL = 'https://open-api.bingx.com';
299
 
300
  // Toggle API Form
@@ -335,6 +335,9 @@
335
 
336
  // Fetch from API
337
  async function fetchFromAPI(endpoint, params = {}) {
 
 
 
338
  params.timestamp = Date.now();
339
  params.recvWindow = 5000; // Optional, check if needed
340
  // Do not include apiKey in params
@@ -342,7 +345,10 @@
342
  params.signature = signature;
343
  const url = `${API_BASE_URL}${endpoint}?${new URLSearchParams(params)}`;
344
  const response = await fetch(url, { method: 'GET', headers: { 'X-BX-APIKEY': API_KEY } });
345
- if (!response.ok) throw new Error(`API Error: ${response.statusText}`);
 
 
 
346
  return response.json();
347
  }
348
 
@@ -473,6 +479,10 @@
473
  document.querySelectorAll('.trading-card h3').forEach(el => el.textContent = 'Loading...');
474
  document.getElementById('trading-table-body').innerHTML = '<tr><td colspan="8" class="py-4 text-center">Loading...</td></tr>';
475
 
 
 
 
 
476
  const [balance, positions, trades] = await Promise.all([
477
  fetchBalance(),
478
  fetchOpenPositions(),
@@ -500,7 +510,7 @@
500
  document.getElementById('allocation-update').textContent = `Last updated: ${new Date().toLocaleTimeString()}`;
501
  } catch (error) {
502
  console.error('Error fetching data:', error);
503
- alert('Failed to sync with BingX API. Please check your API credentials or network.');
504
  }
505
  }
506
 
 
293
  });
294
 
295
  // API Configuration
296
+ let API_KEY = localStorage.getItem('bingxApiKey') || ''; // Removed default hardcoded value
297
+ let API_SECRET = localStorage.getItem('bingxApiSecret') || ''; // Removed default hardcoded value
298
  const API_BASE_URL = 'https://open-api.bingx.com';
299
 
300
  // Toggle API Form
 
335
 
336
  // Fetch from API
337
  async function fetchFromAPI(endpoint, params = {}) {
338
+ if (!API_KEY || !API_SECRET) {
339
+ throw new Error('API Key and Secret are not set. Please enter your credentials.');
340
+ }
341
  params.timestamp = Date.now();
342
  params.recvWindow = 5000; // Optional, check if needed
343
  // Do not include apiKey in params
 
345
  params.signature = signature;
346
  const url = `${API_BASE_URL}${endpoint}?${new URLSearchParams(params)}`;
347
  const response = await fetch(url, { method: 'GET', headers: { 'X-BX-APIKEY': API_KEY } });
348
+ if (!response.ok) {
349
+ const errorText = await response.text();
350
+ throw new Error(`API Error ${response.status}: ${errorText}`);
351
+ }
352
  return response.json();
353
  }
354
 
 
479
  document.querySelectorAll('.trading-card h3').forEach(el => el.textContent = 'Loading...');
480
  document.getElementById('trading-table-body').innerHTML = '<tr><td colspan="8" class="py-4 text-center">Loading...</td></tr>';
481
 
482
+ if (!API_KEY || !API_SECRET) {
483
+ throw new Error('Please enter your BingX API Key and Secret in the credentials form.');
484
+ }
485
+
486
  const [balance, positions, trades] = await Promise.all([
487
  fetchBalance(),
488
  fetchOpenPositions(),
 
510
  document.getElementById('allocation-update').textContent = `Last updated: ${new Date().toLocaleTimeString()}`;
511
  } catch (error) {
512
  console.error('Error fetching data:', error);
513
+ alert(`Failed to sync with BingX API: ${error.message}. Please check your credentials, network, or BingX API documentation.`);
514
  }
515
  }
516