snoowrap
snoowrap copied to clipboard
Make documentation examples more idiomatic
not a big issue, but in the documentation you write your promises like this.
r.getHot({limit: 25}).then(myListing => {
console.log(myListing.length); // => 25
myListing.fetchMore({amount: 10}).then(extendedListing => {
console.log(extendedListing.length); // => 35
})
});
when it should be written like this. Otherwise you are defeating the point of promises.
r.getHot({limit: 25})
.then(myListing => {
console.log(myListing.length); // => 25
return myListing.fetchMore({amount: 10})
})
.then(extendedListing => {
console.log(extendedListing.length); // => 35
});
Thanks for the report. I agree that the code example you pointed out could be written better -- feel free to make a PR if you'd like.
I wasn't 100% sure were I was supposed to change the code, but here is the PR.
and now the 2021 version.
const myListing = await r.getHot({limit: 25});
console.log(myListing.length); // => 25
const extendedListing = await myListing.fetchMore({amount: 10});
console.log(extendedListing.length); // => 35