Jamie Warburton
Jamie Warburton

Reputation: 33

Can I make a request to the Search endpoint with multiple params under the `sort` key?

I'm creating a search page on my website, that is powered by GetCandy's API. Part of the criteria is to have a sort by dropdown filter for changing sorts.

I can see the API returns an array of sort data like this:

[
    { name: 'desc' },
]

Does that mean it can return multiple sorts?

If so, I am wondering how to pass multiple sorts back to the API in a request.

I know I can make a request with { sort: 'name-desc' } to give me a single sort. What do I need to do to concatenate sorts?

Upvotes: 1

Views: 69

Answers (1)

Jamie Warburton
Jamie Warburton

Reputation: 33

You are able to pass multiple sort criteria by concatenating them with the | pipe.

E.G.:

{ 
    sort: 'name-desc|price' 
}

Upvotes: 1

Related Questions