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

Wrong way to use promises #36

Open
MartialSeron opened this issue Feb 23, 2018 · 1 comment
Open

Wrong way to use promises #36

MartialSeron opened this issue Feb 23, 2018 · 1 comment
Assignees
Labels
bug documentation hacktoberfest month-long celebration of open source software
Milestone

Comments

@MartialSeron
Copy link

Considering your code with promises in README.md, I wonder if you understand how we use them?
You take the path to the pyramid of doom.

This is the correct way to use promises :

const client = new GlpiRestClient(config.apirest);
client.initSessionByCredentials(config.user.name, config.user.password, config.appToken)
.then((res) => {
  // Do your stuff here
  return client.getActiveProfile();
})
.then((res) => {
  // Do your stuff here
  return client.killSession();
})
.catch((err) => {
  console.log(err);
});

hth

@ajsb85 ajsb85 added this to the 1.0 milestone Feb 27, 2018
@Gianfranco97
Copy link
Contributor

@MartialSeron Thank you very much for the feedback, we will take it into account to update our code examples.

@ajsb85 ajsb85 added the hacktoberfest month-long celebration of open source software label Oct 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug documentation hacktoberfest month-long celebration of open source software
Projects
None yet
Development

No branches or pull requests

3 participants