【发布时间】:2021-09-15 08:59:49
【问题描述】:
我有一个问题,我看不到错误。
我使用 Next.js 制作的应用程序使用 API 来获取货币值。
在本地,日期和价格会在修改时更新。但在生产中它不起作用,它只显示部署完成时加载的最后一个数据。
我在索引中使用getStaticProps 来获取每个货币类别的数据。
export default function Home({ oficial, blue, bolsa, turista, contadoliqui }) {
return (
<Layout>
<Box p={10}>
<Stack
display={{ md: "flex" }}
spacing={8}
direction={["column", "column", "row"]}
>
<DolarOficialCard oficial={oficial} />
<DolarBlueCard blue={blue} />
</Stack>
<Stack
display={{ md: "flex" }}
spacing={8}
mt={8}
direction={["column", "column", "row"]}
>
<DolarBolsaCard bolsa={bolsa} />
<DolarContado contadoliqui={contadoliqui} />
</Stack>
<Box direction={["column", "column", "row"]} spacing={8} mt={8}>
<DolarTuristaCard turista={turista} />
</Box>
<Box align="center" mt={50}>
<Alert status="info" justifyContent="center">
<AlertIcon />
Última Actualización: {oficial.fecha}
</Alert>
</Box>
</Box>
</Layout>
);
}
export const getStaticProps = async () => {
const oficial = await getDolarOficial();
const blue = await getDolarBlue();
const bolsa = await getDolarBolsa();
const turista = await getDolarTurista();
const contadoliqui = await getDolarLiqui();
return {
props: {
oficial,
blue,
bolsa,
turista,
contadoliqui,
},
};
};
【问题讨论】:
标签: javascript reactjs next.js