我尝试在控制台上打印MongoDB集合(collection 1Data)中的所有文档,但没有任何内容出现。我不确定问题是什么,我认为console.log语句的位置可能不正确。控制台未显示错误console.log(collection1Data.value.filter(data =〉isRecentlyUpdated(data.updatedAt));
<script setup>
import { ref, onMounted } from 'vue';
import axios from 'axios';
const collection1Data = ref([]);
const collection2Data = ref([]);
const fetchData = async () => {
const [collection1Response, collection2Response] = await Promise.all([
axios.get('https://koh-ontvsound:53500/onboardshows'),
axios.get('https://koh-ontvsound:53500/onboardlands'),
]);
collection1Data.value = collection1Response.data;
collection2Data.value = collection2Response.data;
console.log(collection1Data.value.filter(data => isRecentlyUpdated(data.updatedAt)));
};
onMounted(() => {
fetchData();
setInterval(fetchData, 1000);
});
const isRecentlyUpdated = (updatedAt) => {
const updatedTime = new Date(updatedAt);
return (Date.now() - updatedTime.getTime()) < 15000;
};
</script>
1条答案
按热度按时间e0bqpujr1#
你没有解析传入的响应数据