Skip to content

Instantly share code, notes, and snippets.

@Kelin2025
Last active August 22, 2017 18:29
Show Gist options
  • Save Kelin2025/36a3fe7ee9a1afea5123f842b4afc2be to your computer and use it in GitHub Desktop.
Save Kelin2025/36a3fe7ee9a1afea5123f842b4afc2be to your computer and use it in GitHub Desktop.
Example of incorrect API calls
/* Example of boilerplate api call */
let res = await get('/posts')
if (res.success) {
/*
Place data somewhere, success alert etc.
I really feel sorry for people
who still writes so in every call
just copy-paste and don't worry about
And I pretty sure that most of you will say
"Wtf do you talk? There is no another way"
*/
} else {
/*
Alert or do something you usually do on error
That part often can be replaced
in throughout the project
just by Ctrl+H in folder
because the code is the same everywhere
*/
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment