【发布时间】:2021-09-17 18:29:46
【问题描述】:
我想从端点 (GET) 聚合 JSON 数据,因此我在端点内进行了多次提取。这是终点:
export async function get({ params }) {
let sortedByDate = loadStays().sort((a, b) => { return b.datedebpassage - a.datedebpassage });
await Promise.all(sortedByDate.map(async (stay) => {
const res = await fetch("http://localhost:3000/api/visits/" + stay.visitId);
if (res.ok) {
stay.visits = await res.json();
} else {
stay.visits = [];
}
}));
return {
body: sortedByDate,
};
}
问题是关于 url http://localhost:3000:如何使用与主端点相同的主机名?
谢谢
【问题讨论】: