我在代码中调用了两次getStatisticsRangDay ,两次调用只在开始和结束时间上有所区别。其中一次的代码如下,但是今天调用这个api,只能得到到其中某一次数据,无法多次调用。报错如下,报错提示为服务器繁忙,目前其他几个统计相关的api测试后都没有这个报错,目前这个报错只出现在getStatisticsRangDay 上。
出现的报错
Code: Select all
Error fetching data: {"errorCode": 40015, "errorMsg": "miniapp highway request error", "innerError": {"errorMsg": "Error Domain=com.thing.www Code=500 "server busy" UserInfo={NSLocalizedDescription=server busy}", "errorCode": "500"}} params {"devId": "。。。", "dpId": "3", "startDay": "20240901", "endDay": "20240904"}
调用代码
Code: Select all
const fetchWeek = () => {
const currentDate = new Date();
const currentDayOfWeek = currentDate.getDay();
const formatDate = (date) => {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
return `${year}${month}${day}`;
};
const startDay = formatDate(new Date(currentDate.setDate(currentDate.getDate() - currentDayOfWeek)));
const endDay = formatDate(new Date());
fetchData(getStatisticsRangDay, setDeviceWeek, setDevicesumWeek, {
devId: 。。。。,
dpId: '3',
startDay,
endDay,
});
};