Format of Datetime in API reference

Hi,

i’d like to retrieve top selling products from 1 month ago.
In the API reference there is a query string “from” that accept a Datetime type.

I’m trying something like this:

let d = new Date()
d.setMonth(d.getMonth() - 1)
d.toISOString()
const products = await axios.get(`https://app.snipcart.com/api/products?from=${d}&orderBy=nbrSales`

is it right?

Hi there,

You seem to understand the purpose of this parameter correctly. Do you have any specific issue trying to make this work?

By looking at your snippet, there is a problem with your date output: toIsoString() returns the string but you are not saving it in a variable. You either need to save the value of d.toISOString() to a const and include this value in your request or include it directly in your string ${d.toISOString()}.

Can you provide more details if you are still having some issues with this call?

Cheers!