top | item 20808274

(no title)

1f97 | 6 years ago

can anyone tell me why he says that the axios snippet is wrong?

discuss

order

grenoire|6 years ago

You catch an error to proceed with the expected behaviour, for one.

mdemare|6 years ago

Why use anonymous functions for control flow? Nearly any other language would either return an error or throw an exception.

pluma|6 years ago

Presumably 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|6 years ago

That 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).

tasqyn|6 years ago

because nested ifs, I think.

vonseel|6 years ago

Idk where he was going with that, I think he either doesn’t know what nested means or he was referencing different codez

1f97|6 years ago

i don't see nested ifs? from what i can tell, it checks whether the error happened in the request or in the response from the server.