const fakeUrl = 'https://api.github.co'
function getUser(url) {
return new Promise((resolve, reject) => {
fetch(url).then(data => resolve(data.json())).catch(err => reject(err))
})
}
const app = async () => {
const result = await getUser(fakeUrl)
console.log(result)
console.log('end')
}
app()
const fakeUrl = 'https://api.github.co'
function getUser(url) {
return new Promise((resolve, reject) => {
fetch(url).then(data => resolve(data.json())).catch(err => reject(err))
})
}
const app = async () => {
try {
const result = await getUser(fakeUrl)
console.log(result)
} catch (error) {
console.log('error', error)
}
console.log('end')
}
app()