Reputation: 12399
I'm trying to init my parameters so I can run getProducts()
, as well as
getProducts({
query: {},
p: {
offset: 0,
sort: {
_id: 1
},
limit: 25,
count: 0
}
})
. So far, only the latter works, using this function :
getProducts({
query = {},
pagination: {
offset = 0,
sort = {
_id: 1
},
limit = 25
}
}) {
console.log(offset, limit, sort)
}
I'm pretty sure I'm missing something simple on initialisation, but can't figure out what, even with the MDN docs.
Upvotes: 0
Views: 148
Reputation: 5584
Your code is not following the Object destructuring syntax as you can see here, check this:
function getProducts({query, pagination: {offset, limit, sort}} = {query: {},pagination: {offset: 0, limit: 25, sort: {_id: 1}}}){
console.log(query, offset, limit, sort);
}
getProducts()
getProducts({query: {}, pagination: {offset: 10, limit: 50, sort: {_id: -1}}})
Upvotes: 1