Last active
July 28, 2021 08:17
-
-
Save peterkarn/c7fd6fd683337153252abd84e980dff7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getResource = async (url) => { | |
const response = await fetch(url); | |
if (!response.ok) { | |
throw new Error(`Ошибка по адресу ${url}, статус ошибки ${response.status}`) | |
} | |
return await response.json(); | |
}; | |
getResource('https://jsonplaceholder.typicode.com/todos/23').then((data) => { | |
console.log(data); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment