Skip to content

Instantly share code, notes, and snippets.

@ichiroku11
Created February 5, 2018 06:09
Show Gist options
  • Select an option

  • Save ichiroku11/61f5bdc7ba683dd9387d921a42017b22 to your computer and use it in GitHub Desktop.

Select an option

Save ichiroku11/61f5bdc7ba683dd9387d921a42017b22 to your computer and use it in GitHub Desktop.
fetchとasync/awaitのサンプル
// fetchを使ってjsonを読み込む
const testAsync = async () => {
const response = await fetch("sample.json");
// sample.json
// { "message": "Hello, World!" }
const json: { message: string; } = await response.json();
console.log(json.message);
// Hello, World!
};
testAsync();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment