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

docs(Filesystem): use await in writeFile example #2087

Merged
merged 2 commits into from
Oct 25, 2019

Conversation

bvx89
Copy link
Contributor

@bvx89 bvx89 commented Oct 23, 2019

Updated the example-code for the Filesystem.writeFile({ ... })-method to include the await keyword.

Add missing `await` in example.
Copy link
Member

@jcesarmobile jcesarmobile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be able to use await, then fileWrite function should be async.

Since there is nothing going on after writeFile, it's not really necessary to await, but if you want to add it you need to make the function async

@bvx89
Copy link
Contributor Author

bvx89 commented Oct 25, 2019

https://capacitor.ionicframework.com/docs/apis/filesystem#method-writeFile-0

It says in the documentation that it returns a promise. It's not strictly necessary to await, but the example code uses a try-catch that would never catch anything.

Edit: Okay, I understand what you mean. My point still stands that the try-catch wouldn't catch anything, but I will add the async prefix to the example function as well.

Copy link
Member

@jcesarmobile jcesarmobile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you are right, it won't catch anything unless you await.
Well spotted!

@jcesarmobile jcesarmobile changed the title docs(cap-plugins): Fix bug in example docs(Filesystem): use await in writeFile example Oct 25, 2019
@jcesarmobile jcesarmobile merged commit e374f2e into ionic-team:master Oct 25, 2019
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

Successfully merging this pull request may close these issues.

2 participants