6 ms·
can anyone tell me why he says that the axios snippet is wrong?
by 1f97 7y ago
can anyone tell me why he says that the axios snippet is wrong?
- grenoire 7y agoYou catch an error to proceed with the expected behaviour, for one.
- tasqyn 7y agobecause nested ifs, I think.
- pluma 7y agoPresumably because a rEaL pRoGrAmMiNg LaNgUaGe would have used different exception types to provide the same levels of distinction which still results in basically the same if/else-if/else (or try/catch/catch) structure but "more civilised". Or because he thinks web apps don't care about whether the server couldn't be reached and whether the server rejected a request. Your guess is as good as mine.
- vonseel 7y agoThat makes a lot more sense than my assumption (based on his next paragraph) that he just didn’t like chained ‘if’ statements. His mention of “nested ifs” threw me off tremendously, considering that code block doesn’t contain any nested ifs (chained if/else is not the same as nested ifs).
- mdemare 7y agoWhy use anonymous functions for control flow? Nearly any other language would either return an error or throw an exception.