3 ms·
The page has a 2023 last-edited on it, but the code snippet (if you follow the GH link) hasn't been touched in two years. If their JS docs are anything like th
by yamtaddle 3y ago
The page has a 2023 last-edited on it, but the code snippet (if you follow the GH link) hasn't been touched in two years.
If their JS docs are anything like their Android docs, Google's terrible about updating examples.
- hot_gril 3y agoasync/await is still pretty old by now. Maybe they wanted to be consistent with even older examples. I dunno, every single thing Google-related uses promises, so I'm thinking they're partial to that for some reason. Another example from 4mo ago: https://github.com/kubernetes-client/javascript/blob/master/examples/ingress.js https://github.com/kubernetes-client/javascript/blob/master/... (the catch at the end is a promise catch)
- WorldMaker 3y agoThere's a tiny benefit of the doubt to be given here that while async/await is several years old, support for "top-level await" was only more recently standardized and took too long for common LTS versions of Node to also support it. All of these examples appear to be top-level and perhaps they didn't want to write them as async functions or IIFEs, especially for error-handling code.
- hot_gril 3y agoThat makes sense, someone copy-pasting async code into a JS console would get errors not too long ago. There's nobody to blame for this but myself, just wish I discovered earlier on how async/await works, along with other modern JS stuff that you won't see everywhere because it's new.