Sobes.tech
Middle

/** * The `asyncAuth(callback)` function takes a callback, * which can be passed an error (as the first argument) and data * from the backend (as the second argument). * asyncAuth((error, data) => {}); * * You need to implement the `auth()` function, * which calls `asyncAuth()`, but returns a Promise. * * @returns {Promise} */ export function auth() { // asyncAuth((error, data) => {}); }

sobes.tech AI

Answer from AI

To wrap a callback function in a Promise, you need to create and return a new Promise inside auth, in which you call asyncAuth and invoke resolve or reject inside the callback.

export function auth() {
  return new Promise((resolve, reject) => {
    asyncAuth((error, data) => {
      if (error) {
        reject(error);
      } else {
        resolve(data);
      }
    });
  });
}
/** * The `asyncAuth(callback)` function takes a… - sobes.tech