Skip to content

Instantly share code, notes, and snippets.

@etoxin
Created November 19, 2018 04:09
Show Gist options
  • Save etoxin/36ef59ba3942dca6832ce419ee9001eb to your computer and use it in GitHub Desktop.
Save etoxin/36ef59ba3942dca6832ce419ee9001eb to your computer and use it in GitHub Desktop.
Nice small clean Service
/**
* API Service
* @async
* @returns {Promise<Object>}
*/
async function Service() {
let response = await fetch('/api.json');
if (response.ok) return await response.json();
throw new Error(response.statusText);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment