question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mention async/await usage somewhere in the docs?

See original GitHub issue

Superagent fully supports async/await. It’s documented here: https://visionmedia.github.io/superagent/#promise-and-generator-support


I think folks would be interested to know that you can already using superagent with async/await like so:

async function () {
  try {
    var response = await request.post('/user/').send({foo: 4})
  } catch (err) {
    // do something with err...
  }
}

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:5
  • Comments:16 (8 by maintainers)

github_iconTop GitHub Comments

41reactions
kornelskicommented, Apr 8, 2016

In 2.0 we support real promises in .then(), so there’s no need to wrap .end():

const response = await request.post('/foo');

should just work. I don’t mind adding that to the documentation.

29reactions
crookedneighborcommented, Apr 8, 2016

May I ask what the point of adding the documentation would be? If you’re using async/await, you should see that superagent can return a promise and know that you can use async/await on it. If you’re not using it, and aren’t familiar with async/await, the documentation would be confusing unless you also mention that you need to transpile code from es7 to use it. Seems like more trouble than it is worth IMO.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mention async/await usage somewhere in the docs? #957
I think folks would be interested to know that you can already using superagent with async/await like so: async function () { try...
Read more >
async function - JavaScript - MDN Web Docs - Mozilla
The async function declaration declares an async function where the await keyword is permitted within the function body. The async and await ......
Read more >
From JavaScript Promises to Async/Await: why bother?
First, async/await makes the asynchronous code appear and behave like synchronous code. Being that it was built on top of Promises , you...
Read more >
Why do I need to await an async function when it is not ...
await only blocks execution internal to the async function. It does not block anything outside of the function. Conceptually, an async function ...
Read more >
Using Async/Await with Mongoose
Basic Use. Async/await lets us write asynchronous code as if it were synchronous. This is especially helpful for avoiding callback hell when executing ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found