Airtable API——如何正确编码多个字段/方向的排序 URI 组件?
例如,此排序对象具有三个字段和方向:
const sort = [
{ field: "title", direction: "asc" },
{ field: "value", direction: "desc" },
{ field: "category", direction: "asc" }
];
在我的查询生成器函数中,到目前为止我有这个,但它是不正确的:
let sortUri;
sort.forEach(sort => {
console.log(sort.field, sort.direction);
sortUri += `&sort%5B0%5D%5Bfield%5D=${encodeURIComponent(
sort.field
)}&sort%5B0%5D%5Bdirection%5D=${sort.direction}`;
});
sortUri;