Assign variables in function Javascript [duplicate]

I have the next function in javascript:

const getData = () => {
  let res = null;
  let err = null;
  service
    .get('/users')
    .then((response) => {
      if (response) {
        res = response;
        return response;
      }
      throw new Error(response);
    })
    .catch((e) => {
      err = null;
      return e;
    });

  return {
    res,
    err
  }
};

Even i get the response when i do:

console.log(getData())

… i get both values as null.
Why values are not assigned and how to get the result?