News for hackers. Stuff that matters.
Re:JavaScript Is Bad by 1f97 on Tuesday August 27, 2019 @07:13AM (#20808274)
can anyone tell me why he says that the axios snippet is wrong?
Re:JavaScript Is Bad by grenoire on Tuesday August 27, 2019 @07:18AM (#20808305)
You catch an error to proceed with the expected behaviour, for one.
Re:JavaScript Is Bad by mdemare on Tuesday August 27, 2019 @10:23AM (#20809856)
Why use anonymous functions for control flow? Nearly any other language would either return an error or throw an exception.
Re:JavaScript Is Bad by pluma on Tuesday August 27, 2019 @08:06AM (#20808670)
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.

Re:JavaScript Is Bad by vonseel on Tuesday August 27, 2019 @08:19AM (#20808766)
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).
Re:JavaScript Is Bad by tasqyn on Tuesday August 27, 2019 @07:18AM (#20808318)
because nested ifs, I think.
Re:JavaScript Is Bad by vonseel on Tuesday August 27, 2019 @08:20AM (#20808774)
Idk where he was going with that, I think he either doesn’t know what nested means or he was referencing different codez
Re:JavaScript Is Bad by 1f97 on Tuesday August 27, 2019 @07:32AM (#20808428)
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.