api
This commit is contained in:
parent
7c4f609442
commit
ffaf738960
|
|
@ -1,6 +1,6 @@
|
||||||
// API服务层,用于与后端进行交互
|
// API服务层,用于与后端进行交互
|
||||||
|
|
||||||
const API_BASE_URL = 'http://localhost:3000/api';
|
const API_BASE_URL = '/api';
|
||||||
|
|
||||||
// 通用请求函数
|
// 通用请求函数
|
||||||
async function request(url, options = {}) {
|
async function request(url, options = {}) {
|
||||||
|
|
@ -12,11 +12,11 @@ async function request(url, options = {}) {
|
||||||
...options.headers
|
...options.headers
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error(`HTTP error! status: ${response.status}`);
|
throw new Error(`HTTP error! status: ${response.status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return await response.json();
|
return await response.json();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('API request error:', error);
|
console.error('API request error:', error);
|
||||||
|
|
@ -187,4 +187,4 @@ export default {
|
||||||
statistics: statisticsApi,
|
statistics: statisticsApi,
|
||||||
waterBill: waterBillApi,
|
waterBill: waterBillApi,
|
||||||
electricityBill: electricityBillApi
|
electricityBill: electricityBillApi
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue