update pay ui
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
// src/services/eventService.js
|
||||
|
||||
import { logger } from '../utils/logger';
|
||||
import { getApiBase } from '../utils/apiConfig';
|
||||
|
||||
/**
|
||||
* 格式化股票代码,确保包含交易所后缀
|
||||
@@ -39,11 +40,12 @@ const formatStockCode = (code) => {
|
||||
const apiRequest = async (url, options = {}) => {
|
||||
const method = options.method || 'GET';
|
||||
const requestData = options.body ? JSON.parse(options.body) : null;
|
||||
const fullUrl = `${getApiBase()}${url}`;
|
||||
|
||||
logger.api.request(method, url, requestData);
|
||||
logger.api.request(method, fullUrl, requestData);
|
||||
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
const response = await fetch(fullUrl, {
|
||||
...options,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@@ -55,16 +57,16 @@ const apiRequest = async (url, options = {}) => {
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text();
|
||||
const error = new Error(`HTTP error! status: ${response.status}`);
|
||||
logger.api.error(method, url, error, { errorText, ...requestData });
|
||||
logger.api.error(method, fullUrl, error, { errorText, ...requestData });
|
||||
throw error;
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
logger.api.response(method, url, response.status, data);
|
||||
logger.api.response(method, fullUrl, response.status, data);
|
||||
|
||||
return data;
|
||||
} catch (error) {
|
||||
logger.api.error(method, url, error, requestData);
|
||||
logger.api.error(method, fullUrl, error, requestData);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user