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]: minimise promise chaining #261

Closed
wants to merge 2 commits into from
Closed

[enhancement]: minimise promise chaining #261

wants to merge 2 commits into from

Conversation

pulkit-30
Copy link

fix: #216

Description

Minimize promise chaining in asynchronous functions.
replaced .then with “async - await” wherever possible.

Changes

Example changes in src/components/Footer/index.jsx file:

Before

  const fetchVersion = () => {
    return getFossologyVersion()
      .then((res) => {
        setSessionStorage("fossologyVersion", res);
        setVersion(res);
        return res;
      })
      .catch(() => null);
};

After

 const fetchVersion = async () => {
    try {
      const res = await getFossologyVersion();
      setSessionStorage("fossologyVersion", res);
      setVersion(res);
      return res;
    } catch (error) {
      return null;
    }
  };

@pulkit-30 pulkit-30 marked this pull request as ready for review September 8, 2022 05:56
@shaheemazmalmmd shaheemazmalmmd added needs review Need code review needs test Needs testing labels Oct 11, 2022
@pulkit-30
Copy link
Author

@GMishx please review this PR

@GMishx
Copy link
Member

GMishx commented Nov 10, 2022

@pulkit-30 , please squash the commits into 1 commit and change the commit message as per the contributing guidelines.

@GMishx
Copy link
Member

GMishx commented Nov 10, 2022

@Shruti3004 , please review this branch.

@pulkit-30 pulkit-30 closed this by deleting the head repository May 6, 2023
@lata-11 lata-11 mentioned this pull request Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs review Need code review needs test Needs testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Minimise promise chaining in asynchronous functions (ES6)
3 participants