Is adding finally block really necessary in try...catch

Viewed 221

So i have been searching, is using a finally really necessary, and i guess i haven't found the answer i was looking for my type of use case. Here is the code example:

async fetchFromBackend() {
  this.isLoading = true;
  try {
    const res = await fetchData();
    return res;
  } catch (e) {
    console.log(e);
  }
  this.isLoading = false;
}

from the code above, the reassignment of this.isLoading won't be executed until it has done with the await without needing to put it inside a finally regardless it will throw an error or not. Can someone elaborate if this would be the best practice or if the reassignment outside of try...catch suffice?

0 Answers
Related