Reputation: 325
I am having trouble getting the data from jsonplaceholder.com
I tried using promise:
fetch('https://jsonplaceholder.typicode.com/users')
.then(resp => resp.json())
.then(console.log)
Then I tried the same thing using async function:
async function fetchUsers() {
const resp = await fetch('https://jsonplaceholder.typicode.com/users')
const data = await resp.json()
console.log(data)
}
fetchUsers()
Either way, I get an error.
I am studying a course where the tutor had no problem fetching the function using both async and promise:
Please help
Upvotes: 0
Views: 3563
Reputation: 325
@HacKaTun3s's comment worked for me: "You cant fetch from a new tab page. Navigate to google.com and try the same thing again."
Upvotes: 4