Closed garrettdowd closed 4 years ago
@garrettdowd If you come from Python and you are familiar with the Twisted framework, Promises are kind of like Deferred in Twisted.
You can use them in 2 ways, using their .then()
method, or await
ing for them in an async function:
// using .then
myPromise
.then(r => console.log(r))
.catch(e => console.error(e))
// using async/await
async function test() {
const r = await myPromise
console.log(r)
}
// You can also await in a try/catch block
async function test() {
try {
const r = await myPromise
console.log(r)
} catch(e) {
console.error(e)
}
}
Sorry for leaving this open so long. Thank you for the explanation!
Hi there,
Could additional usage examples be included in the README for people not familiar with JS? I am coming from Python, so I am unsure exactly how to use
promises
. Unfortunately, I am having trouble with the basic task of printing the data from the promises to the console.This repo seems to be one of the only viable methods to get the Airbnb data I need. Python alternatives are not great.