Type error with async/await
See original GitHub issueI updated to version 1.19.0 of the package (which includes typings). I get the following error when trying to await promises (Typescript):
Type is referenced directly or indirectly in the fulfillment callback of its own 'then' method
Here are the snippets that receive the error:
const user = await reddit.getUser(query.trim()).fetch() //param is string
const post = await reddit.getRandomSubmission()
const post = await reddit.getSubmission(postIDS[i]).fetch() //param is string
const posts = await reddit.getSubreddit(subreddit).getRandomSubmission() //param is string
This error seems to come from the package. While I don’t see a mention of async/await in the docs, it did work perfectly before…
Issue Analytics
- State:
- Created 4 years ago
- Reactions:20
- Comments:12
Top Results From Across the Web
Error handling with Async/Await in JS | by Ian Segers | ITNEXT
Learn error handling in JS with sync and async code and some caveats. ... now create a new error of type TypeError and...
Read more >Async/Await Error Handling - Beginner JavaScript - Wes Bos
We will talk about error handling strategies for async await in this lesson. Because there is no .then() that we are chaining on...
Read more >Error handling with async/await and promises, n² ... - CatchJS
When dealing with promises, you have no way of knowing if an error will be handled some time in the future. The promise...
Read more >Async/await - The Modern JavaScript Tutorial
If a promise resolves normally, then await promise returns the result. But in the case of a rejection, it throws the error, just...
Read more >Better error handling with async/await - DEV Community
Async /await is a special syntax to work with promises in a more concise way. Adding async before any function turns the function...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
A better quick fix is putting this in a ts file in your project. This way you don’t need to cast or use a function. This then fixes it globally.
Another hack/workaround for this is to use
Omit<>
type in TypeScript: