【发布时间】:2019-10-29 18:02:45
【问题描述】:
我有一个 ID 列表,即:[3,6,7] 我想从 api 中获取所有具有 3,6 和 7 作为 id 的对象。 我只能用一个 ID 来获取它。像这样:
const response = await fetch(`http://localhost:3000/api`, {
method: 'POST',
headers: {
'Content-Type': 'application/json; charset=utf-8',
},
body: JSON.stringify({
id: 7,
}),
});
如何获取不同的 ID? 提前致谢。
【问题讨论】:
-
使用
response = await Promise.all([fetch(...id1), fetch(...id2), fetch(...id3)])
标签: javascript node.js reactjs postgresql fetch