Problems async method

Here’s what I would recommend:

  • forget that async and await exist for now;
  • read this post outlining three types of asynchronous functions, and decide which each of yours is;
  • pick a naming convention and follow it - here’s Google’s, for example;
  • declare proper types (no any) for every variable, parameter, and function return type;
  • never nest then or subscribe - if you feel the need to, break the task into a separate smaller function.

This will be frustrating, but following these rules will help your build tools guide you towards how to structure code clearly and avoid lots of common bugs. It will get more intuitive, eventually.

1 Like