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

🚀 Enhancement: change the code snippets from promises syntax to async await #886

Open
2 tasks done
pushpitkamboj opened this issue Apr 13, 2024 · 1 comment
Open
2 tasks done
Labels
enhancement New feature or request

Comments

@pushpitkamboj
Copy link

pushpitkamboj commented Apr 13, 2024

🔖 Enhancement description

can we please change the syntax to create, update, signin, login code snippets in the JS language,
because it is now an older syntax. It will be more convinient if we use async await syntaxes

🎤 Pitch

for example the snippet to singup NOW is
import { Client, Account, ID } from "appwrite";

const client = new Client()
.setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
.setProject('<PROJECT_ID>'); // Your project ID

const account = new Account(client);

const promise = account.create('[USER_ID]', '[email protected]', '');

promise.then(function (response) {
console.log(response); // Success
}, function (error) {
console.log(error); // Failure
});

IT CAN BE IMPROVED BY THIS ASYNC SYNTAX INSTEAD OF PROMISES, WHICH HAVE DEMERITS LIKE PROMISE CHAINING

const client = new Client();
const account = new account();

constructor() {
    this.client
        .setEndpoint('https://cloud.appwrite.io/v1')  //Your API endpoint
        .setProject('<PROJECT_ID>');  //your Project ID
    this.account = new Account(this.client);

}

async createAccount ({response}) {
    try{
       const userAccount =  await this.account.create(response);
      return console.log(response);
    } catch (error) {
        console.log(error);
    }
}

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

@pushpitkamboj pushpitkamboj added the enhancement New feature or request label Apr 13, 2024
@manya706
Copy link

manya706 commented Oct 7, 2024

hi! can i work on this?

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

No branches or pull requests

2 participants