Skip to main content

I’m trying to build a sort URI with multiple sort fields and directions, but I don’t understand the syntax. Suppose I have this sort object with three fields/directions:


const sort = t
{ field: "title", direction: "asc" },
{ field: "value", direction: "desc" },
{ field: "category", direction: "asc" }
];

//I thought I could just daisy chain them like this, but it doesn't work.

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}`;
});

const url = `&filterByFormula=AND(FIND(%221000%22%2C%20%7BLocation%7D)%20%3E%200%2CAND(%7BValue%7D%20%3C%2010000000))${sortUri}`;
Be the first to reply!

Reply