Open adamcoulombe opened 3 years ago
Await constant needs to go in an async function in order for it to work like so:
async function getTweets(){
const { data } = await client.get('tweets', { ids: '1228393702244134912' });
return data
}
getTweets().then(tweets=>{
console.log(tweets);
});
Docs should really be updated to reflect this since it errors out of the box with the example that is given
If the file has a .mjs
extension and import
is used instead of require
, then top-level await is allowed:
import Twitter from 'twitter-v2'
...
const { data } = await client.get('tweets', { ids: '1228393702244134912' })
console.log(data)
Description
await is only valid in async function
when running getting started example in readmeSteps to Reproduce
create a node app with the following code (copied from readme):
Expected behavior:
should log the output of the tweet
Actual behavior:
console error:
await is only valid in async function
Reproduces how often:
100%
Versions
^1.1.0
Additional Information