Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage with async/await. #77

Open
Cristy94 opened this issue Feb 10, 2020 · 2 comments
Open

Usage with async/await. #77

Cristy94 opened this issue Feb 10, 2020 · 2 comments
Assignees

Comments

@Cristy94
Copy link

Cristy94 commented Feb 10, 2020

I currently have this AJAX request, handled with async/await:
const response = await getJSON('getDomains.php');

Can this library be used when the returned promise is awaited?
Is it something like this?
const response = await trackPromise(getJSON(getDomains.php));

@Cristy94
Copy link
Author

This seems to work: const response = await trackPromise(getJSON(getDomains.php));.
Maybe it should be added as an example to the docs.

@brauliodiez
Copy link
Member

That's it, trackPromise returns the promise is tracking so you can use it like you mentioned.

const response = await trackPromise(getJSON(getDomains.php));.

Agree it's a good idea to add an example like that in the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants