fossology / FOSSologyUI

Repository to hold the new UI framework for FOSSology built with React
https://fossology.github.io/FOSSologyUI/
GNU General Public License v2.0
47 stars 85 forks source link

[enhancement]: minimise promise chaining #261

Closed pulkit-30 closed 1 year ago

pulkit-30 commented 2 years ago

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 commented 1 year ago

@GMishx please review this PR

GMishx commented 1 year ago

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

GMishx commented 1 year ago

@Shruti3004 , please review this branch.