ListOrders with pagination turned on throws an error.
Closed this issue · 2 comments
Hey @tyscorp. Thanks a lot for putting this together. Really appreciate it. Not sure if I'm not making the call properly, but I have a setup (to fetch orders) that looks something like so:
var mws = new MWSClient({
accessKeyId: ACCESS_KEY_ID,
secretAccessKey: SECRET_KEY,
merchantId: this._sellerId,
authToken: this._authToken,
host: 'mws-eu.amazonservices.com',
meta: {
retry: true, // retry requests when throttled
next: true, // auto-paginate
limit: Infinity // only get this number of items (NOT the same as MaxRequestsPerPage)
}
})
mws.Orders.ListOrders({
MarketplaceId: marketplaceId,
MaxResultsPerPage: 5,
CreatedAfter: createdAfter,
OrderStatus: ['Unshipped', 'PartiallyShipped']
})
.then(function (result, meta) {
//...
})
.catch(function (err) {
//...
});
When I run this an exception gets thrown at line 168
of lib/client.js
with message: _.get(...) is not a function
. After digging around a bit, I found that the code in question looks like so:
return _.get(this, req.options.next)({ NextToken: nextToken }, nextMeta)
.then(function (nextData) {
return {
result: _.concat(result, nextData.result),
metadata: _.concat(metadata, nextData.metadata)
};
});
I found that the this
object doesn't have a property matching the value of req.options.next
(which evaluates to be ListOrdersByNextToken
), hence the error. ListOrdersByNextToken
exists on this.Orders
instead.
Thanks for the report!
I published v1.1.4 with a fix.
I can't currently test it, but I think it should work... I'll know for sure tomorrow. (or if you confirm it)
I just pulled the update in and it works now. Thanks man 👍